public int Delete(ApplicationEntity application) { using (var db = new SqlConnection(_config)) { const string sql = "UPDATE Applications SET IsDeleted = 1 WHERE Id = @Id AND EafAccount = @EafAccount"; return(db.Execute(sql, application)); } }
public int Update(ApplicationEntity application) { using (var db = new SqlConnection(_config)) { const string sql = "UPDATE Applications SET Name = @Name, LongDescription = @LongDescription, ShortDescription = @ShortDescription WHERE Id = @Id AND EafAccount = @EafAccount"; return(db.Execute(sql, application)); } }
public int Insert(ApplicationEntity application) { using (var db = new SqlConnection(_config)) { const string sql = "INSERT INTO Applications (Name, EafAccount, LongDescription, ShortDescription, IsDeleted) " + "VALUES(@Name, @EafAccount, @LongDescription, @ShortDescription, 0)"; return(db.Execute(sql, application)); } }
public void Delete(ApplicationEntity application) { application.EafAccount = 1; var updateCount = _applicationRepo.Delete(application); if (updateCount == 0) { throw new Exception("Application was not deleted"); } }
public void Update(ApplicationEntity application) { application.EafAccount = 1; application.IsDeleted = false; SetDescriptions(application); var updateCount = _applicationRepo.Update(application); if (updateCount == 0) { throw new Exception("Application was not updated"); } }
public void Create(ApplicationEntity application) { application.EafAccount = 1; application.IsDeleted = false; SetDescriptions(application); var insertCount = _applicationRepo.Insert(application); if (insertCount == 0) { throw new Exception("Application was not created"); } }
private static void SetDescriptions(ApplicationEntity application) { if (application.LongDescription == null) { application.LongDescription = ""; } else if (application.LongDescription.Length > 250) { application.ShortDescription = application.LongDescription?.Substring(0, 250); } else { application.ShortDescription = application.LongDescription; } }
public void Put([FromRoute] int id, [FromBody] ApplicationEntity application) { _applicationService.Update(application); }
public void Post([FromBody] ApplicationEntity application) { _applicationService.Create(application); }
public int Delete(ApplicationEntity application) { throw new NotImplementedException(); }
public int Insert(ApplicationEntity application) { throw new NotImplementedException(); }