public ApplicationRoleDTO Post([FromBody] RoleAccessMappingRequest data) { ApplicationRole current = ApplicationRole.NewApplicationRole(); data.Role.UpdatedBy = CurrentUserID; current.CustomSave(data); return(ApplicationRole.GetByApplicationRoleID(current.ApplicationRoleID).CurrentDTO); }
public void CustomSave(RoleAccessMappingRequest data) { bool cancel = false; OnUpdating(ref cancel); data.Role.CustomCopyDTO(this); using (var connection = new SqlConnection(ADOHelper.ConnectionString)) { connection.Open(); using (var command = new SqlCommand("[dbo].[spCFM_ApplicationRole_CustomUpdate]", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@p_ApplicationRoleID", data.Role.ApplicationRoleID); if (data.Role.ApplicationRoleID <= 0) { command.Parameters["@p_ApplicationRoleID"].Direction = ParameterDirection.Output; } command.Parameters.AddWithValue("@p_ApplicationRoleName", data.Role.Name); command.Parameters.AddWithValue("@p_SystemRoleID", data.Role.SystemRoleID); command.Parameters.AddWithValue("@p_IsActive", data.Role.IsActive); command.Parameters.AddWithValue("@p_ActionBy", ADOHelper.NullCheck(data.Role.UpdatedBy)); command.Parameters.AddWithValue("@p_BusinessAreaIDs", ADOHelper.NullCheck(data.BusinessAreaIDs)); command.Parameters.AddWithValue("@p_BusinessDivisionIDs", ADOHelper.NullCheck(data.BusinessDivisionIDs)); command.Parameters.AddWithValue("@p_BusinessEntitieIDs", ADOHelper.NullCheck(data.BusinessEntityIDs)); command.Parameters.AddWithValue("@p_HomeIDs", ADOHelper.NullCheck(data.HomeIDs)); command.Parameters.AddWithValue("@p_ClientIDs", ADOHelper.NullCheck(data.ClientIDs)); //result: The number of rows changed, inserted, or deleted. -1 for select statements; 0 if no rows were affected, or the statement failed. int result = command.ExecuteNonQuery(); _applicationRoleIDProperty = (System.Int32)command.Parameters["@p_ApplicationRoleID"].Value; if (result == 0) { throw new DBConcurrencyException("The entity is out of date on the client. Please update the entity and try again. This could also be thrown if the sql statement failed to execute."); } } //UpdateChildren(this, connection); //FieldManager.UpdateChildren(this, connection); } OnUpdated(); }