/// <summary> /// Saves this instance. /// </summary> /// <returns></returns> public static bool SaveOrUpdate(Resolution entity) { if (entity == null) throw new ArgumentNullException("entity"); if (entity.ProjectId <= Globals.NEW_ID) throw (new ArgumentException("Cannot save resolution, the project id is invalid")); if (string.IsNullOrEmpty(entity.Name)) throw (new ArgumentException("The resolution name cannot be empty or null")); if (entity.Id > Globals.NEW_ID) return DataProviderManager.Provider.UpdateResolution(entity); var tempId = DataProviderManager.Provider.CreateNewResolution(entity); if (tempId <= 0) return false; entity.Id = tempId; return true; }
/// <summary> /// Adds the milestone. /// </summary> /// <param name="s">The s.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void AddResolution(Object s, EventArgs e) { var newName = txtName.Text.Trim(); if (newName == String.Empty) return; var newResolution = new Resolution { ProjectId = ProjectId, Name = newName, ImageUrl = lstImages.SelectedValue}; if (ResolutionManager.SaveOrUpdate(newResolution)) { txtName.Text = ""; BindResolutions(); lstImages.SelectedValue = String.Empty; } else { ActionMessage.ShowErrorMessage(LoggingManager.GetErrorMessageResource("SaveResolutionError")); } }
/// <summary> /// Updates the resolution. /// </summary> /// <param name="resolutionToUpdate">The resolution to update.</param> /// <returns></returns> public override bool UpdateResolution(Resolution resolutionToUpdate) { // Validate Parameters if (resolutionToUpdate == null) throw (new ArgumentNullException("resolutionToUpdate")); using (var sqlCmd = new SqlCommand()) { AddParamToSqlCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null); AddParamToSqlCmd(sqlCmd, "@ResolutionId", SqlDbType.Int, 0, ParameterDirection.Input, resolutionToUpdate.Id); AddParamToSqlCmd(sqlCmd, "@SortOrder", SqlDbType.Int, 0, ParameterDirection.Input, resolutionToUpdate.SortOrder); AddParamToSqlCmd(sqlCmd, "@ProjectId", SqlDbType.Int, 0, ParameterDirection.Input, resolutionToUpdate.ProjectId); AddParamToSqlCmd(sqlCmd, "@ResolutionName", SqlDbType.NText, 50, ParameterDirection.Input, resolutionToUpdate.Name); AddParamToSqlCmd(sqlCmd, "@ResolutionImageUrl", SqlDbType.NText, 50, ParameterDirection.Input, resolutionToUpdate.ImageUrl); SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_RESOLUTION_UPDATE); ExecuteScalarCmd(sqlCmd); return ((int)sqlCmd.Parameters["@ReturnValue"].Value == 0); } }
public abstract bool UpdateResolution(Resolution resolutionToUpdate);
// Resolution public abstract int CreateNewResolution(Resolution resolutionToCreate);