public IHttpActionResult PutUserAccount(int id, UserAccount userAccount) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != userAccount.UserAccountID) { return StatusCode(HttpStatusCode.BadRequest); } try { _user.UpdateUserAccount(userAccount); } catch (DBConcurrencyException) { if (!UserAccountExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult PostUserAccount(UserAccount userAccount) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.CreateUserAccount(userAccount); return CreatedAtRoute("DefaultApi", new { id = userAccount.UserAccountID }, userAccount); }
public UserAccount CreateUserAccount(UserAccount oUserAccount) { UserAccount oUserAccountReturn = null; using (DBContext) { try { oUserAccountReturn = DBContext.UserAccounts.Add(oUserAccount); DBContext.SaveChanges(); } catch (Exception ex) { throw ex; } } return oUserAccountReturn; }
public UserAccount UpdateUserAccount(UserAccount oUserAccount) { UserAccount oUserAccountReturn = null; if (oUserAccount != null && oUserAccount.UserAccountID > 0) { using (DBContext) { UserAccount u = this.GetUserAccountByID(oUserAccount.UserAccountID); if (u != null) { Mapper.Map<UserAccount, UserAccount>(oUserAccount, u); DBContext.SaveChanges(); oUserAccountReturn = u; } } } return oUserAccountReturn; }
public IHttpActionResult PostUserAccount(string UserName, string Password) { if (UserName == null || Password == null) { return StatusCode(HttpStatusCode.BadRequest); } UserAccount userAccount = new UserAccount(); userAccount.UserName = UserName; userAccount.IsActive = false; userAccount.IsDeleted = false; userAccount.Password = Encoding.ASCII.GetBytes(Password); if (!ModelState.IsValid) { return BadRequest(ModelState); } _user.CreateUserAccount(userAccount); return CreatedAtRoute("DefaultApi", new { id = userAccount.UserAccountID }, userAccount); }
/// <summary> /// Converts this instance of <see cref="UserAccountDTO"/> to an instance of <see cref="UserAccount"/>. /// </summary> /// <param name="dto"><see cref="UserAccountDTO"/> to convert.</param> public static UserAccount ToEntity(this UserAccountDTO dto) { if (dto == null) return null; var entity = new UserAccount(); entity.UserAccountID = dto.UserAccountID; entity.UserID = dto.UserID; entity.UserName = dto.UserName; entity.Password = dto.Password; entity.IsActive = dto.IsActive; entity.IsDeleted = dto.IsDeleted; entity.insuser = dto.insuser; entity.insdt = dto.insdt; entity.upduser = dto.upduser; entity.upddt = dto.upddt; dto.OnEntity(entity); return entity; }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="entity"><see cref="UserAccount"/> converted from <see cref="UserAccountDTO"/>.</param> static partial void OnEntity(this UserAccountDTO dto, UserAccount entity);