public int SaveSMSLimit(SMSLimitDTO SMSLimitDetail) { smsbookinglimit smslimitEntity = new smsbookinglimit(); AutoMapper.Mapper.Map(SMSLimitDetail, smslimitEntity); if (SMSLimitDetail.SMSLimit_Id == 0) { using (TransactionScope transactionScope = new TransactionScope()) { ESalesUnityContainer.Container.Resolve<IGenericRepository<smsbookinglimit>>().Save(smslimitEntity); IList<SMSLimitDTO> lstSMSLimitDTO = ESalesUnityContainer.Container.Resolve<ISMSLimitService>().GetSMSLimitList(DateTime.Now.Date.AddDays(0)); foreach (SMSLimitDTO smsLimitDTO in lstSMSLimitDTO) { if (smsLimitDTO.SMSLimit_Id != smslimitEntity.SMSLimit_Id) { smsbookinglimit upSmsLimitEntity = new smsbookinglimit(); smsLimitDTO.SMSLimit_IsActive = false; AutoMapper.Mapper.Map(smsLimitDTO, upSmsLimitEntity); ESalesUnityContainer.Container.Resolve<IGenericRepository<smsbookinglimit>>().Update(upSmsLimitEntity); } } transactionScope.Complete(); } } return smslimitEntity.SMSLimit_Id; }
protected void grdSMSLimit_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals(Globals.GridCommandEvents.ADDNEW)) { if (Page.IsValid) { IList<SMSRegistrationDTO> lstCustomerDTO = ESalesUnityContainer.Container.Resolve<ISMSService>().GetTotalSMSDetailsForDate(DateTime.Now.Date.AddDays(0)); int accepted = lstCustomerDTO.Count(F => F.SMSReg_BookingStatus == true); GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer); SMSLimitDTO SMSLimitDetails = new SMSLimitDTO(); if (Convert.ToInt32(((TextBox)row.FindControl("txtNewSMSLimit")).Text) > accepted) { SMSLimitDetails.SMSLimit_Limit = Convert.ToInt32(((TextBox)row.FindControl("txtNewSMSLimit")).Text); SMSLimitDetails.SMSLimit_Date = DateTime.Now.Date; SMSLimitDetails.SMSLimit_IsActive = true; SMSLimitDetails.SMSLimit_CreatedDate = DateTime.Now; SMSLimitDetails.SMSLimit_LastUpdatedDate = DateTime.Now; SMSLimitDetails.SMSLimit_CreatedBy = GetCurrentUserId(); SMSLimitDetails.SMSLimit_AuthorizedBy = ((TextBox)row.FindControl("txtAuthorizedBy")).Text; ESalesUnityContainer.Container.Resolve<ISMSLimitService>().SaveSMSLimit(SMSLimitDetails); ucMessageBoxForGrid.ShowMessage(Resources.Messages.SMSLimitSavedSuccessfully); GetSMSLimit(); } else { ucMessageBoxForGrid.ShowMessage(Resources.Messages.InvalidSMSLimit); } } } }