public SubGroupDTO Update(SubGroupDTO updatedRecord) { try { string query = @" UPDATE SubGroups SET SubGroupCode = @SubGroupCode ,SubGroupName = @SubGroupName ,SubGroupDescription = @SubGroupDescription ,ProductGroupID = @ProductGroupID WHERE SubGroupID = @SubGroupID"; var queryParameters = new DynamicParameters(); queryParameters.Add("@SubGroupID", updatedRecord.SubGroupID); queryParameters.Add("@ProductGroupID", updatedRecord.ProductGroupID); queryParameters.Add("@SubGroupCode", updatedRecord.SubGroupCode); queryParameters.Add("@SubGroupName", updatedRecord.SubGroupName); queryParameters.Add("@SubGroupDescription", updatedRecord.SubGroupDescription); int rowsUpdated = Connection.Execute(query, queryParameters, CurrentTrans); return((rowsUpdated > 0) ? GetByID(updatedRecord.SubGroupID) : throw noRecordEX); } catch (Exception ex) { throw SqlExceptionHandler.HandleSqlException(ex) ?? ex; } }
public async Task <IActionResult> PutSubGroup([FromRoute] int id, [FromBody] SubGroupDTO subGroupDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != subGroupDto.ID) { return(BadRequest()); } var subGroup = await _context.SubGroups.FirstOrDefaultAsync(s => s.ID == subGroupDto.ID); subGroup.Name = subGroupDto.Name; subGroup.GroupId = subGroupDto.Group.ID; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubGroupExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void tblSubGroup_insert(SubGroupDTO dt) { string sql = "INSERT INTO tblSubGroup(GroupID, CustomerID, GroupName) " + "VALUES(@GroupID, @CustomerID, @GroupName)"; cmd = new SqlCommand(sql, ConnectionData._MyConnection); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@GroupID", SqlDbType.Int).Value = dt.GroupID; cmd.Parameters.Add("@CustomerID", SqlDbType.Int).Value = dt.CustomerID; cmd.Parameters.Add("@GroupName", SqlDbType.NVarChar).Value = dt.GroupName; cmd.ExecuteNonQuery(); cmd.Dispose(); }
public SubGroupDTO Update(SubGroupDTO newModel) { try { SubGroupDTO returnModel = UOW.SubGroupRepo.Update(newModel); UOW.SaveChanges(); return(returnModel); } catch (Exception ex) { UOW.RollbackChanges(); throw ex; } }
public void tblSubGroup_Update(SubGroupDTO dt) { string sql = "UPDATE tblSubGroup SET "+ "GroupID = @GroupID, "+ "CustomerID = @CustomerID, GroupName=@GroupName WHERE IDSubGroup = @IDSubGroup"; cmd = new SqlCommand(sql, ConnectionData._MyConnection); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@IDSubGroup", SqlDbType.Int).Value = dt.IDSubGroup; cmd.Parameters.Add("@GroupID", SqlDbType.Int).Value = dt.GroupID; cmd.Parameters.Add("@CustomerID", SqlDbType.Int).Value = dt.CustomerID; cmd.Parameters.Add("@GroupName", SqlDbType.NVarChar).Value = dt.GroupName; cmd.ExecuteNonQuery(); cmd.Dispose(); }
public async Task <IActionResult> PostSubGroup([FromBody] SubGroupDTO subGroupDto) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.SubGroups.Add(new SubGroup() { Name = subGroupDto.Name, GroupId = subGroupDto.Group.ID }); await _context.SaveChangesAsync(); return(Ok()); }
public SubGroupDTO Update(SubGroupDTO newModel) { return(_subGroupService.Update(newModel)); }
public void tblSubGroup_Update(SubGroupDTO dt) { sgDAO.tblSubGroup_Update(dt); }
public void tblSubGroup_insert(SubGroupDTO dt) { sgDAO.tblSubGroup_insert(dt); }
public ActionResult <SubGroupDTO> Update([FromBody] SubGroupDTO newModel) { try { return(_subGroupManager.Update(newModel)); } catch (BaseCustomException ex) { return(BadRequest(ex.Message)); } }