public bool Update(IdentityProperty identity) { //Common syntax var sqlCmd = @"Property_Update"; //For parameters var parameters = new Dictionary <string, object> { { "@Id", identity.Id }, { "@Name", identity.Name }, { "@Code", identity.Code }, { "@PropertyCategoryId", identity.PropertyCategoryId }, { "@Status", identity.Status } }; try { using (var conn = new SqlConnection(_connectionString)) { MsSqlHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, sqlCmd, parameters); } } catch (Exception ex) { var strError = "Failed to execute Property_Update. Error: " + ex.Message; throw new CustomSQLException(strError); } return(true); }
public IdentityProperty GetById(int Id) { var info = new IdentityProperty(); var sqlCmd = @"Property_GetById"; var parameters = new Dictionary <string, object> { { "@Id", Id } }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { while (reader.Read()) { info = ExtractPropertyData(reader); } } } } catch (Exception ex) { var strError = "Failed to execute Property_GetPropertyById. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public int Insert(IdentityProperty identity) { var newId = 0; var sqlCmd = @"Property_Insert"; var parameters = new Dictionary <string, object> { { "@Name", identity.Name }, { "@Code", identity.Code }, { "@PropertyCategoryId", identity.PropertyCategoryId }, { "@Status", identity.Status } }; try { using (var conn = new SqlConnection(_connectionString)) { var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters); if (reader.Read()) { newId = Utils.ConvertToInt32(reader[0]); } } } catch (Exception ex) { var strError = "Failed to Property_Insert. Error: " + ex.Message; throw new CustomSQLException(strError); } return(newId); }
private IdentityProperty ExtractEditFormData(PropertyEditModel formData) { var myIdetity = new IdentityProperty(); myIdetity.Id = formData.Id; myIdetity.Name = formData.Name; myIdetity.Icon = formData.Icon; myIdetity.Status = formData.Status; myIdetity.PropertyCategoryId = formData.PropertyCategoryId; return(myIdetity); }
public IdentityProperty ExtractPropertyData(IDataReader reader) { var record = new IdentityProperty(); //Seperate properties record.Id = Utils.ConvertToInt32(reader["Id"]); record.Name = reader["Name"].ToString(); record.Code = reader["Code"].ToString(); record.Status = Utils.ConvertToInt32(reader["Status"]); record.PropertyCategoryId = Utils.ConvertToInt32(reader["PropertyCategoryId"]); return(record); }
private PropertyEditModel RenderEditModel(IdentityProperty identity) { var editModel = new PropertyEditModel(); editModel.Id = identity.Id; editModel.Name = identity.Name; editModel.Icon = identity.Icon; editModel.Status = identity.Status; editModel.LangList = identity.LangList; editModel.PropertyCategoryId = identity.PropertyCategoryId; return(editModel); }
private IdentityProperty ExtractCreateFormData(PropertyCreateModel formData) { var myIdetity = new IdentityProperty(); myIdetity.Name = formData.Name; //myIdetity.UrlFriendly = UrlFriendly.ConvertToUrlFriendly(formData.Name); myIdetity.Icon = formData.Icon; myIdetity.Status = Utils.ConvertToInt32(formData.Status); myIdetity.CreatedBy = User.Identity.GetUserId(); myIdetity.PropertyCategoryId = formData.PropertyCategoryId; return(myIdetity); }
public IdentityPropertyDto GetIdentityProperty(int?id) { IdentityPropertyDto identityPropertyDto = new IdentityPropertyDto(); if (!id.HasValue && id.GetValueOrDefault() <= 0) { return(identityPropertyDto); } IdentityProperty identityProperty = this.Session.Get <IdentityProperty>(id.Value); if (identityProperty == null) { return(identityPropertyDto); } return(identityProperty.ToModel()); }
public ActionResult Index(PropertyModel model) { int currentPage = 1; int pageSize = SystemSettings.DefaultPageSize; if (string.IsNullOrEmpty(model.SearchExec)) { model.SearchExec = "Y"; if (!ModelState.IsValid) { ModelState.Clear(); } } if (Request["Page"] != null) { currentPage = Utils.ConvertToInt32(Request["Page"], 1); } var filter = new IdentityProperty { Keyword = !string.IsNullOrEmpty(model.Keyword) ? model.Keyword.Trim() : null, Status = model.Status == null ? -1 : (int)model.Status }; try { model.SearchResults = _mainStore.GetByPage(filter, currentPage, SystemSettings.DefaultPageSize); if (model.SearchResults != null && model.SearchResults.Count > 0) { model.TotalCount = model.SearchResults[0].TotalCount; model.CurrentPage = currentPage; model.PageSize = pageSize; } } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed to get data because: " + ex.ToString()); return(View(model)); } return(View(model)); }
public IdentityProperty GetDetail(int Id) { var info = new IdentityProperty(); var sqlCmd = @"Property_GetDetail"; var parameters = new Dictionary <string, object> { { "@Id", Id } }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { //Get base info if (reader.Read()) { info = ExtractPropertyData(reader); } //Get data for all languages if (reader.NextResult()) { while (reader.Read()) { var langItem = new IdentityPropertyLang(); langItem.Id = Utils.ConvertToInt32(reader["Id"]); langItem.LangCode = reader["LangCode"].ToString(); langItem.Name = reader["Name"].ToString(); langItem.PropertyId = Utils.ConvertToInt32(reader["PropertyId"]); info.LangList.Add(langItem); } } } } } catch (Exception ex) { var strError = "Failed to execute Property_GetDetail. Error: " + ex.Message; throw new CustomSQLException(strError); } return(info); }
public void UpdateIdentityProperty(int id, IdentityPropertyDto identityPropertyDto) { var transaction = this.Session.BeginTransaction(); try { IdentityProperty identityProperty = this.Session.Get <IdentityProperty>(id); identityProperty = identityPropertyDto.ToEntity(identityProperty); this.Session.Update(identityProperty); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } }
public List <IdentityProperty> GetByPage(IdentityProperty filter, int currentPage, int pageSize) { //Common syntax var sqlCmd = @"Property_GetByPage"; List <IdentityProperty> listData = null; //For paging int offset = (currentPage - 1) * pageSize; //For parameters var parameters = new Dictionary <string, object> { { "@Keyword", filter.Keyword }, { "@Status", filter.Status }, { "@Offset", offset }, { "@PageSize", pageSize }, }; try { using (var conn = new SqlConnection(_connectionString)) { using (var reader = MsSqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, sqlCmd, parameters)) { listData = ParsingListPropertyFromReader(reader); } } } catch (Exception ex) { var strError = "Failed to execute Property_GetByPage. Error: " + ex.Message; throw new CustomSQLException(strError); } return(listData); }
public List <IdentityProperty> GetByPage(IdentityProperty filter, int currentPage, int pageSize) { return(myRepository.GetByPage(filter, currentPage, pageSize)); }
public bool Update(IdentityProperty identity) { return(myRepository.Update(identity)); }
public static IdentityProperty ToEntity(this IdentityPropertyDto identityResourcePropertyDto, IdentityProperty identityResourceProperty = null) { return(Mapper.Map <IdentityPropertyDto, IdentityProperty>(identityResourcePropertyDto, identityResourceProperty)); }
public static IdentityPropertyDto ToModel(this IdentityProperty identityResourceProperty) { return(Mapper.Map <IdentityPropertyDto>(identityResourceProperty)); }
public ActionResult UpdateProperty(PropertyEditModel model) { var msg = ManagerResource.LB_OPERATION_SUCCESS; var isSuccess = false; if (!ModelState.IsValid) { string messages = string.Join("; ", ModelState.Values .SelectMany(x => x.Errors) .Select(x => x.ErrorMessage + x.Exception)); this.AddNotification(messages, NotificationType.ERROR); return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = messages })); } try { //Begin db transaction var data = new IdentityProperty(); data.PropertyCategoryId = model.PropertyCategoryId; data.Id = model.Id; data.Code = model.Code; data.Name = model.Name; data.Status = (int)EnumStatus.Activated; var storeProperty = GlobalContainer.IocContainer.Resolve <IStoreProperty>(); if (model.Id > 0) { //Update storeProperty.Update(data); //Clear cache CachingHelpers.ClearPropertyCategoryCache(); } else { //Add new var newId = storeProperty.Insert(data); if (newId > 0) { isSuccess = true; //Clear cache CachingHelpers.ClearPropertyCategoryCache(); return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = ManagerResource.LB_OPERATION_SUCCESS, clientcallback = " location.reload()" })); } } isSuccess = true; } catch (Exception ex) { this.AddNotification(NotifSettings.Error_SystemBusy, NotificationType.ERROR); logger.Error("Failed for UpdateProperty request: " + ex.ToString()); return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = NotifSettings.Error_SystemBusy })); } return(Json(new { success = isSuccess, title = ManagerResource.LB_NOTIFICATION, message = msg, clientcallback = " location.reload()" })); }
public int Insert(IdentityProperty identity) { return(myRepository.Insert(identity)); }