protected void grdOwnershipStatus_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (Page.IsValid) { //To update ownershipStatus OwnershipStatusDTO ownershipDetail = new OwnershipStatusDTO(); ownershipDetail = ESalesUnityContainer.Container.Resolve<IMasterService>() .GetOwnershipStatusListById(Convert.ToInt32(grdOwnershipStatus.DataKeys[e.RowIndex].Value)); ownershipDetail.OwnershipStatus_Name = ((TextBox)grdOwnershipStatus.Rows[e.RowIndex].FindControl("txtOwnershipStatus")).Text; ownershipDetail.OwnershipStatus_LastUpdatedDate = DateTime.Now; ownershipDetail.OwnershipStatus_CreatedBy = GetCurrentUserId(); int ownershipStatusId = ESalesUnityContainer.Container.Resolve<IMasterService>() .SaveAndUpdateOwnershipStatus(ownershipDetail); ucMessageBoxForGrid.ShowMessage(Resources.Messages.OwnershipStatusUpdatedSuccessfully); } }
protected void grdOwnershipStatus_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == Globals.GridCommandEvents.ADDNEW) { if (Page.IsValid) { GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer); OwnershipStatusDTO ownershipDetail = new OwnershipStatusDTO(); ownershipDetail.OwnershipStatus_Name = ((TextBox)row.FindControl("txtNewOwnershipStatus")).Text; ownershipDetail.OwnershipStatus_CreatedDate = DateTime.Now; ownershipDetail.OwnershipStatus_LastUpdatedDate = DateTime.Now; ownershipDetail.OwnershipStatus_CreatedBy = GetCurrentUserId(); int OwnershipStatusId = ESalesUnityContainer.Container.Resolve<IMasterService>() .SaveAndUpdateOwnershipStatus(ownershipDetail); GetOwnershipStatus(); ucMessageBoxForGrid.ShowMessage(Resources.Messages.OwnershipStatusSavedSuccessfully); } } }
/// <summary> /// Get Ownership Status List By Id /// </summary> /// <param name="ownershipStatusId">int32:ownershipStatusId</param> /// <returns></returns> public OwnershipStatusDTO GetOwnershipStatusListById(int ownershipStatusId) { OwnershipStatusDTO ownershipStatusDetails = new OwnershipStatusDTO(); AutoMapper.Mapper.Map(base.OwnershipStatusRepository.GetSingle(item => item.OwnershipStatus_Id == ownershipStatusId), ownershipStatusDetails); return ownershipStatusDetails; }
/// <summary> /// Verify Ownership Status Exists or not by ownershipStatusId and ownershipStatus /// </summary> /// <param name="ownershipStatusId"></param> /// <param name="ownershipStatus"></param> /// <returns></returns> bool IMasterService.IsOwnershipStatusExists(int ownershipStatusId, string ownershipStatus) { OwnershipStatusDTO ownershipDetail = new OwnershipStatusDTO(); bool result = false; if (ownershipStatusId == 0) { AutoMapper.Mapper.Map(base.OwnershipStatusRepository.GetSingle(item => item.OwnershipStatus_Name == ownershipStatus && item.OwnershipStatus_IsDeleted == false), ownershipDetail); } else { AutoMapper.Mapper.Map(base.OwnershipStatusRepository.GetSingle(item => item.OwnershipStatus_Name == ownershipStatus && item.OwnershipStatus_IsDeleted == false && item.OwnershipStatus_Id != ownershipStatusId), ownershipDetail); } if (ownershipDetail.OwnershipStatus_Id > 0) { result = true; } return result; }
/// <summary> /// Save And Update Ownership Status /// </summary> /// <param name="ownershipDetail"></param> /// <returns></returns> public int SaveAndUpdateOwnershipStatus(OwnershipStatusDTO ownershipDetail) { ownershipstatu ownershipStatusEntity = new ownershipstatu(); AutoMapper.Mapper.Map(ownershipDetail, ownershipStatusEntity); if (ownershipDetail.OwnershipStatus_Id == 0) { base.OwnershipStatusRepository.Save(ownershipStatusEntity); } else { base.OwnershipStatusRepository.Update(ownershipStatusEntity); } return ownershipStatusEntity.OwnershipStatus_Id; }