Skip to content

Commit

Permalink
- Modified for second relaease.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknown authored and unknown committed Nov 21, 2014
1 parent 78f545c commit c6b011d
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .nuget/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.0.0" />
<package id="Microsoft.AspNet.WebApi" version="5.2.2" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net45" />
Expand Down
2 changes: 1 addition & 1 deletion FSDTS/Common/FsdtsConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public class FsdtsConstants

public const int SMTPPort = 587;

public const System.Net.Mail.SmtpDeliveryMethod SMTPDeliveryMethod = "SmtpDeliveryMethod.Network";
public const System.Net.Mail.SmtpDeliveryMethod SMTPDeliveryMethod = SmtpDeliveryMethod.Network;

#endregion

Expand Down
2 changes: 1 addition & 1 deletion FSDTS/Controllers/ProgramController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public IHttpActionResult GetProgram(int id)
/// <returns></returns>
public IQueryable<Program> GetProgramsByOrgId(int Oid)
{
return db.Program.Where(pr => pr.OrganizationId == Oid).AsQueryable();
return db.Program.Where(pr => pr.OrganizationId == Oid).OrderBy(pr => pr.ProgramName).AsQueryable();
}

/// <summary>
Expand Down
1 change: 1 addition & 0 deletions FSDTS/Controllers/ProjectOrganizationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public List<Participant> GetProjectOrganizationsByProjectId(int Pid)
{
objparticipant = new Participant();
objparticipant.ProjOrgId = Convert.ToInt32(reader["ProjectOrganizationId"]);
objparticipant.OrgId = Convert.ToInt32(reader["OrganizationId"]);
objparticipant.ProjectName = Convert.ToString(reader["ProjectName"]);
objparticipant.OrganizationName = Convert.ToString(reader["OrganizationName"]);
objparticipant.Format = Convert.ToString(reader["format"]);
Expand Down
119 changes: 116 additions & 3 deletions FSDTS/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ namespace FSDTS.Controllers
{
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Http;
Expand All @@ -19,13 +21,18 @@ namespace FSDTS.Controllers
using FSDTS.Common;
using FSDTS.Models;
using log4net;
using Microsoft.AspNet.Identity;

/// <summary>
/// UserController class.
/// For CRUD operation related to User.
/// </summary>
public class UserController : ApiController
{
SqlConnection con = null;
SqlCommand cmd = null;
SqlDataReader reader = null;
User objuser = new User();
/// <summary>
/// Creating Log object to log stack trace and flow of execution.
/// </summary>
Expand All @@ -46,9 +53,105 @@ public class UserController : ApiController
public IQueryable<User> GetUser()
{
Log.Info(FsdtsConstants.GettingItemList);
return db.User.OrderBy(user => user.UserFirstName);
return db.User.OrderBy(user => user.UserLastName);
}


[Route("Api/GetUserInfo")]
public List<User> GetUserInfo()
{
cmd = new SqlCommand();
List<User> lstUser = new List<User>();
con = new SqlConnection(Convert.ToString(ConfigurationManager.ConnectionStrings["FSDTSContext"]));
User oParticipant = new User();

if (con.State == ConnectionState.Closed || con.State == ConnectionState.Broken)
con.Open();

cmd.Connection = con;

cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "FSDTD_GetUserInfo";

reader = cmd.ExecuteReader();
while (reader.Read())
{
objuser = new User();
objuser.UserId = Convert.ToInt32(reader["UserId"]);
objuser.UserFirstName = Convert.ToString(reader["UserFirstName"]);
objuser.UserLastName = Convert.ToString(reader["UserLastName"]);
objuser.UserEmail = Convert.ToString(reader["UserEmail"]);
objuser.UserAddressLine1 = Convert.ToString(reader["UserAddressLine1"]);
objuser.UserAddressLine2 = Convert.ToString(reader["UserAddressLine2"]);
objuser.UserCity = Convert.ToString(reader["UserCity"]);
objuser.UserState = Convert.ToString(reader["UserState"]);
objuser.UserZip = Convert.ToString(reader["UserZip"]);
objuser.UserNotes = Convert.ToString(reader["UserNotes"]);
objuser.UserLastEditedOn = Convert.ToDateTime(reader["UserLastEditedOn"]);
objuser.UserLastEditedBy = Convert.ToString(reader["UserLastEditedBy"]);
objuser.UserPhoneNumber = Convert.ToString(reader["UserPhoneNumber"]);
objuser.OrganizationId = Convert.ToInt32(reader["OrganizationId"]);
objuser.UserStatus = Convert.ToString(reader["UserStatus"]);
lstUser.Add(objuser);
}
cmd.Dispose();
con.Dispose();
return lstUser;
//return db.ProjectOrganization.Where(p => p.IsDeleted == false).AsQueryable();
}

[Route("Api/GetUserInfoById")]
public List<User> GetUserInfoById(int Uid)
{
cmd = new SqlCommand();
List<User> lstUser = new List<User>();
con = new SqlConnection(Convert.ToString(ConfigurationManager.ConnectionStrings["FSDTSContext"]));
User oParticipant = new User();

if (con.State == ConnectionState.Closed || con.State == ConnectionState.Broken)
con.Open();

cmd.Connection = con;

cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "FSDTD_GetUserInfoById";

SqlParameter param = new SqlParameter();
param.Direction = ParameterDirection.Input;
param.DbType = DbType.Int32;
param.ParameterName = "@UserId";
param.Precision = 10;
param.SqlDbType = SqlDbType.Int;
param.SqlValue = Uid;
param.Value = Uid;
cmd.Parameters.Add(param);

reader = cmd.ExecuteReader();
while (reader.Read())
{
objuser = new User();
objuser.UserId = Convert.ToInt32(reader["UserId"]);
objuser.UserFirstName = Convert.ToString(reader["UserFirstName"]);
objuser.UserLastName = Convert.ToString(reader["UserLastName"]);
objuser.UserEmail = Convert.ToString(reader["UserEmail"]);
objuser.UserAddressLine1 = Convert.ToString(reader["UserAddressLine1"]);
objuser.UserAddressLine2 = Convert.ToString(reader["UserAddressLine2"]);
objuser.UserCity = Convert.ToString(reader["UserCity"]);
objuser.UserState = Convert.ToString(reader["UserState"]);
objuser.UserZip = Convert.ToString(reader["UserZip"]);
objuser.UserNotes = Convert.ToString(reader["UserNotes"]);
objuser.UserLastEditedOn = Convert.ToDateTime(reader["UserLastEditedOn"]);
objuser.UserLastEditedBy = Convert.ToString(reader["UserLastEditedBy"]);
objuser.UserPhoneNumber = Convert.ToString(reader["UserPhoneNumber"]);
objuser.OrganizationId = Convert.ToInt32(reader["OrganizationId"]);
objuser.UserStatus = Convert.ToString(reader["UserStatus"]);
lstUser.Add(objuser);
}
cmd.Dispose();
con.Dispose();
return lstUser;
//return db.ProjectOrganization.Where(p => p.IsDeleted == false).AsQueryable();
}

/// <summary>
/// GetUser method of UserController class.
/// </summary>
Expand All @@ -69,7 +172,17 @@ public IHttpActionResult GetUser(int id)
Log.Info(FsdtsConstants.ItemWithSpecificID + id + ": " + FsdtsEnums.SearchByIDResult.Success);
return Ok(user);
}


/// <summary>
/// GetUsersByOrgId method is used to get all the User by Organization id.
/// </summary>
/// <param name="Oid"></param>
/// <returns></returns>
public IQueryable<User> GetUsersByOrgId(int Oid)
{
return db.User.Where(usr => usr.OrganizationId == Oid).OrderBy(usr => usr.UserLastName).AsQueryable();
}

/// <summary>
/// PutUser method of UserController class.
/// Changes applied to database according to User object.
Expand Down
14 changes: 7 additions & 7 deletions FSDTS/FSDTS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
<Compile Include="Migrations\201411051054455_initial.cs" />
<Compile Include="Migrations\201411051054455_initial.Designer.cs">
<DependentUpon>201411051054455_initial.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201411181324112_initiald.cs" />
<Compile Include="Migrations\201411181324112_initiald.Designer.cs">
<DependentUpon>201411181324112_initiald.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201411201157401_initiale.cs" />
<Compile Include="Migrations\201411201157401_initiale.Designer.cs">
<DependentUpon>201411201157401_initiale.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Models\AccountBindingModels.cs" />
<Compile Include="Models\AccountViewModels.cs" />
Expand Down Expand Up @@ -352,12 +352,12 @@
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Migrations\201411051054455_initial.resx">
<DependentUpon>201411051054455_initial.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201411181324112_initiald.resx">
<DependentUpon>201411181324112_initiald.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201411201157401_initiale.resx">
<DependentUpon>201411201157401_initiale.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
Expand Down
2 changes: 1 addition & 1 deletion FSDTS/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void EnableCrossDmainAjaxCall()
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods",
"GET, POST,PUT, DELETE");
"GET, POST,PUT, DELETE, PATCH");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers",
"Content-Type, Accept");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age",
Expand Down
1 change: 1 addition & 0 deletions FSDTS/Models/Participant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace FSDTS.Models
public class Participant
{
public int ProjOrgId { get; set; }
public int OrgId { get; set; }
public string ProjectName { get; set; }
public string OrganizationName { get; set; }
public string Format { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion FSDTS/Models/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Project
/// Gets or sets ProjectStartYear: Start Year of the project.
/// </summary>
[Required]
[RegularExpression("^[a-zA-Z]$", ErrorMessage = "Please add numbers as a year and not alphabets.")]
//[RegularExpression("^[a-zA-Z]$", ErrorMessage = "Please add numbers as a year and not alphabets.")]
// [DataType(, ErrorMessage= "Please add numbers as a year and not alphabets.")]
[FSDTS.Common.CustomValidators.ValidateYear(ErrorMessage = "Start year has to be less than end year.")]
public string ProjectStartYear { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions FSDTS/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace FSDTS.Models
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Web;

Expand Down Expand Up @@ -46,6 +47,7 @@ public class User
/// Gets or sets UserPassword: Password of the user.
/// </summary>
[MinLength(6, ErrorMessage = "Password should be at least 6 characters.")]
[DataType(DataType.Password)]
public string UserPassword { get; set; }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion FSDTS/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,PUT,DELETE" />
<add name="Access-Control-Allow-Methods" value="POST,GET,OPTIONS,PUT,DELETE,PATCH" />

</customHeaders>
</httpProtocol>
Expand Down

0 comments on commit c6b011d

Please sign in to comment.