/// <summary> /// To Verify the User /// </summary> /// <CreatedBy>Bhushan Dod</CreatedBy> /// <CreatedDate>2016-10-08</CreatedDate> /// <param name="UserId"></param> /// <param name="DeletedBy"></param> public Result UpdateVerifyUser(long UserId, long ModifiedBy, DARModel objDAR) { Result result; try { ObjUserRepository = new UserRepository(); objCommonMethodManager = new CommonMethodManager(); UserRegistration obj_UserRegistration = ObjUserRepository.GetAll(x => x.UserId == UserId).FirstOrDefault(); if (obj_UserRegistration != null) { obj_UserRegistration.IsLoginActive = true; obj_UserRegistration.IsEmailVerify = true; obj_UserRegistration.ModifiedDate = DateTime.UtcNow; obj_UserRegistration.ModifiedBy = ModifiedBy; ObjUserRepository.SaveChanges(); objDAR.TaskType = (long)TaskTypeCategory.UserUpdate; objDAR.ActivityDetails = DarMessage.UserVerifiedDar(obj_UserRegistration.FirstName + ' ' + obj_UserRegistration.LastName); #region Save DAR result = objCommonMethodManager.SaveDAR(objDAR); #endregion Save DAR return(Result.UpdatedSuccessfully); } else { return(Result.DoesNotExist); } } catch (Exception ex) { throw ex; } }
public bool SaveCostCodeIds(List <long> CostCodeIds, long LocationId, long UserId) { bool IsSaved = false; string action = "I"; string result = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); List <string> CostCodedata = new List <string>(); try { if (CostCodeIds.Count > 0) { foreach (var item in CostCodeIds) { var ChildCostCode = _workorderems.CostCodes.Where(x => x.CCD_CostCode == item).FirstOrDefault(); if (ChildCostCode == null) { } else { var saveCostCodeId = _workorderems.spSetCostCodeLocationMapping(action, LocationId, ChildCostCode.CCD_CCM_CostCode, item); IsSaved = true; CostCodedata.Add(ChildCostCode.CCD_Description); } } } var locationName = _workorderems.LocationMasters.Where(x => x.LocationId == LocationId && x.IsDeleted == false).FirstOrDefault(); result = string.Join(",", CostCodedata.ToArray()); #region Save DAR objDAR.ActivityDetails = DarMessage.AllocateCostCodeForLocation(locationName.LocationName, result); objDAR.TaskType = (long)TaskTypeCategory.AllocateCostcode; objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.LocationId = LocationId; objDAR.DeletedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public bool SaveCostCodeIds(List<long> CostCodeIds, long LocationId)", "Exception While Saving Cost Code to database", LocationId); throw; } return(IsSaved); }
public JsonResult GetStateByCountryID(string CountryID) { int _countryId = 0; if (!string.IsNullOrEmpty(CountryID)) { int.TryParse(CountryID, out _countryId); StateModel State = new StateModel(); CommonMethodManager _CommonMethodManager = new CommonMethodManager(); State.Data = _ICommonMethod.GetStateByCountryId(_countryId); return(Json(State, JsonRequestBehavior.AllowGet)); } else { return(Json(null, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetInsurancePlanByInsurance(string InsuranceCompanyId) { int _companyId = 0; if (!string.IsNullOrEmpty(InsuranceCompanyId)) { int.TryParse(InsuranceCompanyId, out _companyId); InsurancePlanModel State = new InsurancePlanModel(); CommonMethodManager _CommonMethodManager = new CommonMethodManager(); State.InsurancePlanList = _ICommonMethod.GetPlanByInsuranceCompanyId(_companyId); return(Json(State, JsonRequestBehavior.AllowGet)); } else { return(Json(null, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Delete the Rule. /// CreatedBy : Roshan Rahood /// CreatedOn : Feb 25 2015 /// </summary> /// <param name="emailLogId"></param> /// <param name="loggedInUserId"></param> /// <returns></returns> public Result DeleteEmail(long emailLogId, long loggedInUserId) { Result result; try { if (emailLogId > 0) { if (true) { objEmailLogRepository = new EmailLogRepository(); objCommonMethodManager = new CommonMethodManager(); var data = objEmailLogRepository.GetSingleOrDefault(v => v.EmailLogId == emailLogId && v.IsDeleted == false); data.IsDeleted = true; data.DeletedBy = loggedInUserId; data.DeletedOn = DateTime.UtcNow; objEmailLogRepository.Update(data); return(Result.Delete); } else { return(Result.Failed); } } else { return(Result.DoesNotExist); } return(Result.Delete); } catch (Exception) { throw; } }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 18-OCT-2018 /// Created for : To approve miscellaneous data. /// </summary> /// <param name="Obj"></param> /// <returns></returns> public bool ApproveMiscellaneous(List <MiscellaneousListModel> Obj, string UserName, long UserId, long LocationId, long MiscQbkId, long VendorDetailsId) { bool IsApproved = false; long MISNumber = 0; decimal? calculatedAmt = 0; string MISID = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); DateTime date = new DateTime(); long CreatedBy = 0; long Location = 0; bool GetOnceData = false; var UserDetail = new UserModel(); var LocationDetail = new LocationMaster(); string Status = "Approved"; try { if (Obj.Count > 0) { foreach (var item in Obj) { MISID = item.MISId; string id = item.MISId.Split('S')[1]; MISNumber = Convert.ToInt64(id); calculatedAmt += item.InvoiceAmount; Location = item.LocationId; date = Convert.ToDateTime(item.MISDate); CreatedBy = item.Vendor; objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousReject; if (item.Status == "N") { Status = "Reject"; calculatedAmt -= item.InvoiceAmount; objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousReject; } var saveApprove = _workorderems.spSetApprovalForMiscellaneous(item.MId, item.Comment, item.Status, UserId); if (GetOnceData == false) { GetOnceData = true; UserDetail = _workorderems.UserRegistrations.Join(_workorderems.LogMiscellaneous, u => u.UserId, m => m.LMIS_ModifiedBy, (u, m) => new { u, m }). Where(x => x.m.LMIS_MIS_Id == MISNumber). Select(x => new UserModel() { UserName = x.u.FirstName + " " + x.u.LastName, Email = x.u.UserEmail, Location = x.m.LMIS_LocationId }).FirstOrDefault(); LocationDetail = _workorderems.LocationMasters.Where(x => x.LocationId == UserDetail.Location && x.IsDeleted == false).FirstOrDefault(); } #region Save DAR objDAR.ActivityDetails = DarMessage.MiscellaneousApproveReject(LocationDetail.LocationName, MISID, Status); objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.LocationId = UserDetail.Location; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } string Action = "I"; var saveBill = _workorderems.spSetBill(Action, MiscQbkId, null, MISNumber, null, VendorDetailsId, Location, "MIS", calculatedAmt, calculatedAmt, date, null, CreatedBy, null, "Y"); IsApproved = true; } else { IsApproved = true; } if (IsApproved == true) { #region Email var objEmailLogRepository = new EmailLogRepository(); var objEmailReturn = new List <EmailToManagerModel>(); var objListEmailog = new List <EmailLog>(); var objTemplateModel = new TemplateModel(); if (IsApproved == true) { var userData = _workorderems.UserRegistrations.Join(_workorderems.LogMiscellaneous, u => u.UserId, m => m.LMIS_ModifiedBy, (u, m) => new { u, m }). Where(x => x.m.LMIS_MIS_Id == MISNumber).FirstOrDefault(); //Select(x => new UserModel() //{ // UserName = x.u.FirstName + " " + x.u.LastName, // Email = x.u.UserEmail, // Location = x.m.LMIS_LocationId, //}).FirstOrDefault(); var locationName = _workorderems.LocationMasters.Where(x => x.LocationId == userData.m.LMIS_LocationId && x.IsDeleted == false).FirstOrDefault(); if (userData != null) { bool IsSent = false; var objEmailHelper = new EmailHelper(); objEmailHelper.emailid = userData.u.SubscriptionEmail; objEmailHelper.LocationName = locationName.LocationName; objEmailHelper.UserName = userData.u.FirstName + " " + userData.u.LastName; objEmailHelper.MISId = MISID; objEmailHelper.MailType = "APPROVEMISCELLANEOUS"; objEmailHelper.SentBy = UserId; objEmailHelper.LocationID = userData.m.LMIS_LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); IsSent = objEmailHelper.SendEmailWithTemplate(); //Push Notification if (userData.u.DeviceId != null) { string message = PushNotificationMessages.MiscellaneousApprovedReject(objEmailHelper.LocationName, MISID, Status, objEmailHelper.UserName); PushNotification.GCMAndroid(message, userData.u.DeviceId, objEmailHelper); } if (IsSent == true) { var objEmailog = new EmailLog(); try { objEmailog.CreatedBy = UserId; objEmailog.CreatedDate = DateTime.UtcNow; objEmailog.DeletedBy = null; objEmailog.DeletedOn = null; objEmailog.LocationId = userData.m.LMIS_LocationId; objEmailog.ModifiedBy = null; objEmailog.ModifiedOn = null; objEmailog.SentBy = UserId; objEmailog.SentEmail = userData.u.SubscriptionEmail; objEmailog.Subject = objEmailHelper.Subject; objEmailog.SentTo = userData.u.UserId; objListEmailog.Add(objEmailog); } catch (Exception) { throw; } } using (var context = new workorderEMSEntities()) { context.EmailLogs.AddRange(objListEmailog); context.SaveChanges(); } #endregion Email } } else { IsApproved = true; } } return(IsApproved); } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public MiscellaneousListDetails GetListMiscellaneous(long? UserId,long? Location, int? pageIndex, int? numberOfRows, string sortColumnName, string sortOrderBy, long? locationId, string textSearch, string statusType)", "Exception While Getting List of Miscellaneous details.", null); throw; } }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 17-OCT-2018 /// Created For : To save Miscellaneous data /// </summary> /// <param name="Obj"></param> /// <returns></returns> public ServiceResponseModel <MiscellaneousDetails> SaveMiscellaneous(MiscellaneousDetails Obj) { bool IsSaved = false; string Action = ""; var objDAR = new DARModel(); List <string> LocationData = new List <string>(); var CommonManager = new CommonMethodManager(); string MISID = ""; string LocationName = ""; long UserId = 0; long Mis_Id = 0; decimal TotalAmount = 0; try { var data = new MiscellaneousDetails(); var ObjServiceResponseModel = new ServiceResponseModel <MiscellaneousDetails>(); if (Obj.MiscellaneousDetailsmodel.Count > 0) { Action = "I"; foreach (var item in Obj.MiscellaneousDetailsmodel) { var SaveMiscData = _workorderems.spSetMiscellaneous(Action, item.MISId, item.CostCode, item.LocationId, item.VendorId, item.Discription, item.InvoiceAmount, item.InvoiceDate, item.InvoiceDocument, item.UserId, null, "Y"); var locData = _workorderems.LocationMasters.Where(x => x.LocationId == item.LocationId && x.IsDeleted == false).FirstOrDefault(); LocationData.Add(locData.LocationName); MISID = "MIS" + item.MISId.ToString(); Mis_Id = item.MISId; UserId = item.UserId; TotalAmount += Convert.ToDecimal(item.InvoiceAmount); IsSaved = true; } if (IsSaved == true) { ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.SuccessResponse, CultureInfo.CurrentCulture); ObjServiceResponseModel.Message = CommonMessage.SaveSuccessMessage(); ObjServiceResponseModel.Data = null; } else { ObjServiceResponseModel.Response = Convert.ToInt32(ServiceResponse.NoRecord, CultureInfo.CurrentCulture); ObjServiceResponseModel.Message = CommonMessage.NoRecordMessage(); ObjServiceResponseModel.Data = null; } #region Save DAR LocationName = string.Join(",", LocationData.ToArray()); objDAR.ActivityDetails = DarMessage.MiscellaneousCreated(LocationName, MISID); objDAR.TaskType = (long)TaskTypeCategory.MiscellaneousCreated; objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR #region Notification var objNotify = new NotificationDetailModel(); var _ICommonMethod = new CommonMethodManager(); var objModel = new CommonApproval <ApprovalInput>(); var approvalInput = new ApprovalInput(); approvalInput.Amount = TotalAmount; approvalInput.UserId = UserId; approvalInput.ModuleName = "eCounting"; var getRuleData = objModel.GetApprovalRuleData(approvalInput); if (getRuleData != null) { objNotify.CreatedBy = UserId; objNotify.CreatedDate = DateTime.UtcNow; objNotify.AssignTo = getRuleData.UserId; if (MISID != null) { //var id = Convert.ToInt64(MISID); objNotify.MiscellaneousID = Mis_Id; } var saveDataForNotification = _ICommonMethod.SaveNotificationDetail(objNotify); } if (getRuleData.DeviceId != null) { var objEmailHelper = new EmailHelper(); var objTemplateModel = new TemplateModel(); var userData = _workorderems.UserRegistrations.Where(x => x.UserId == UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); objEmailHelper.emailid = getRuleData.Email; objEmailHelper.ManagerName = getRuleData.ManagerName; objEmailHelper.LocationName = LocationName; if (userData != null) { objEmailHelper.UserName = userData.FirstName + " " + userData.LastName; } objEmailHelper.MISId = MISID; //objEmailHelper.InfractionStatus = obj.Status; objEmailHelper.MailType = "APPROVEMISCELLANEOUS"; objEmailHelper.SentBy = UserId; objEmailHelper.LocationID = objDAR.LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); objEmailHelper.IsWorkable = true; if (getRuleData.DeviceId != null) { string message = PushNotificationMessages.MiscellaneousCreate(objNotify.BillID.ToString(), objEmailHelper.UserName, objEmailHelper.LocationName); PushNotificationFCM.FCMAndroid(message, getRuleData.DeviceId, objEmailHelper); } } #endregion Notification return(ObjServiceResponseModel); } else { return(null); } } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public ServiceResponseModel<miscellaneousNumberModel> GetMiscellaneousNumberData(ServiceBaseModel ObjServiceBaseModel)", "Exception While Getting Miscellaneous number.", null); throw; } }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 26-OCT-2018 /// Created for : To save Payment data to database. /// </summary> /// <param name="objPaymentModel"></param> /// <param name="ObjData"></param> /// <returns></returns> public string MakePayment(PaymentModel objPaymentModel, PaymentModel ObjData) { string result = ""; string Action = ""; string Status = "Y"; string PaidStatus = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); try { if (objPaymentModel != null && ObjData != null) { var ChequeNo = Convert.ToInt32(objPaymentModel.ChequeNo); PaidStatus = "Paid"; if (objPaymentModel.ChequeNo != null) { objPaymentModel.Comment = ChequeNo.ToString(); } else if (objPaymentModel.AccNo != null && objPaymentModel.IsCancel == false) { ObjData.VendorId = 0; objPaymentModel.Comment = objPaymentModel.AccNo; } else if (objPaymentModel.CARDNo != null && objPaymentModel.IsCancel == false) { objPaymentModel.Comment = objPaymentModel.CARDNo; } else if (objPaymentModel.AccountNo != null && objPaymentModel.IsCancel == false) { objPaymentModel.Comment = objPaymentModel.AccountNo; } else if (objPaymentModel.Comment != null && objPaymentModel.IsCancel == true) { objPaymentModel.Comment = objPaymentModel.Comment; Status = "X"; PaidStatus = "Canceled"; } Action = "I"; if (objPaymentModel.IsCancel == false) { var savePayment = _workorderems.spSetCompanyAccountTransaction(Action, null, ObjData.VendorId, objPaymentModel.OpeartorCAD_Id, objPaymentModel.CompanyAccountId, ObjData.BillNo, ObjData.BillAmount, ChequeNo, objPaymentModel.Comment, objPaymentModel.UserId, ObjData.LocationId, ObjData.BillType, Status); } if (Status == "Y") { Status = "P"; } var changeStatus = _workorderems.spSetPaymentStatusForBill(ObjData.LLBL_ID, objPaymentModel.Comment, Status, objPaymentModel.UserId); result = CommonMessage.PaymentSave(); } else { result = CommonMessage.PaymentError(); } #region Save DAR var userData = _workorderems.UserRegistrations.Where(x => x.UserId == objPaymentModel.UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == ObjData.LocationId && x.IsDeleted == false).FirstOrDefault(); objDAR.ActivityDetails = DarMessage.PaymentPaidCancel(userData.FirstName + "" + userData.LastName, locationData.LocationName, PaidStatus, ObjData.BillNo); long userId = Convert.ToInt64(objPaymentModel.UserId); objDAR.TaskType = (long)TaskTypeCategory.PaymentApporveCancel; objDAR.UserId = userId; objDAR.CreatedBy = userId; objDAR.LocationId = Convert.ToInt64(objPaymentModel.LocationId); objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public string MakePayment(PaymentModel objPaymentModel)", "Exception While Saving Payment.", objPaymentModel); throw; } return(result); }
/// <summary> /// Created By : Ashwajit Bansod /// Created Date : 20-OCT-2018 /// Created For : To approve and reject bill /// </summary> /// <param name="Obj"></param> /// <param name="UserName"></param> /// <param name="UserId"></param> /// <param name="LocationId"></param> /// <returns></returns> public string ApproveBill(BillListApproveModel Obj, string UserName, long UserId, long LocationId) { bool IsApproved = false; string result = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); string ApproveStatus = ""; try { var userDataItem = _workorderems.UserRegistrations.Where(x => x.UserId == UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); if (Obj != null) { string Action = "I"; if (Obj.Comment == null) { Obj.Status = "Y"; ApproveStatus = "Approved"; } else { Obj.Status = "N"; ApproveStatus = "Rejected"; } var saveBillApprove = _workorderems.spSetApprovalForPreBill(Obj.LBLL_Id, Obj.Comment, Obj.Status, UserId); //var saveApprove = _workorderems.spSetApprovalForBill(Obj.LBLL_Id, Obj.Comment,Obj.Status,UserId); Obj.InvoiceDate = Convert.ToDateTime(Obj.BillDate); var saveSetBill = _workorderems.spSetBill(Action, Obj.QuickBookBillId, null, null, Obj.BillId, Obj.VendorId, LocationId, "Manual Bill", null, Obj.BillAmount, Obj.InvoiceDate, Obj.BillImage, UserId, UserId, "Y"); IsApproved = true; if (Obj.Comment == null) { result = CommonMessage.BillApprove(); } else { result = CommonMessage.BillReject(); } #region Save DAR var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == LocationId && x.IsDeleted == false).FirstOrDefault(); objDAR.ActivityDetails = DarMessage.BillApprovedReject(userDataItem.FirstName + "" + userDataItem.LastName, locationData.LocationName, ApproveStatus); objDAR.TaskType = (long)TaskTypeCategory.BillApprovedReject; objDAR.UserId = UserId; objDAR.CreatedBy = UserId; objDAR.LocationId = LocationId; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } else { IsApproved = true; } if (IsApproved == true) { #region Email var objEmailLogRepository = new EmailLogRepository(); var objEmailReturn = new List <EmailToManagerModel>(); var objListEmailog = new List <EmailLog>(); var objTemplateModel = new TemplateModel(); if (IsApproved == true) { var userData = _workorderems.spGetVendorAllDetail(Obj.VendorId). Select(x => new BillListApproveModel() { Email = x.COD_Email, }).FirstOrDefault(); if (userData != null) { bool IsSent = false; var objEmailHelper = new EmailHelper(); objEmailHelper.emailid = userData.Email; objEmailHelper.LocationName = Obj.LocationName; objEmailHelper.VendorName = Obj.VendorName; objEmailHelper.UserName = userDataItem.FirstName + " " + userDataItem.LastName; objEmailHelper.MailType = "APPROVEBILL"; objEmailHelper.SentBy = UserId; objEmailHelper.LocationID = LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); IsSent = objEmailHelper.SendEmailWithTemplate(); var userDataApprove = _workorderems.LogBills.Join(_workorderems.UserRegistrations, q => q.LBLL_ModifiedBy, u => u.UserId, (q, u) => new { q, u }). Where(x => x.q.LBLL_Id == Obj.LBLL_Id).FirstOrDefault(); //Push Notification if (userDataApprove != null) { if (userDataApprove.u.DeviceId != null) { string message = PushNotificationMessages.BillApprovedReject(objEmailHelper.LocationName, Obj.LBLL_Id, ApproveStatus, objEmailHelper.UserName); PushNotification.GCMAndroid(message, userDataApprove.u.DeviceId, objEmailHelper); } } if (IsSent == true) { var objEmailog = new EmailLog(); try { objEmailog.CreatedBy = UserId; objEmailog.CreatedDate = DateTime.UtcNow; objEmailog.DeletedBy = null; objEmailog.DeletedOn = null; objEmailog.LocationId = LocationId; objEmailog.ModifiedBy = null; objEmailog.ModifiedOn = null; objEmailog.SentBy = UserId; objEmailog.SentEmail = userData.Email; objEmailog.Subject = objEmailHelper.Subject; objEmailog.SentTo = Obj.VendorId; objListEmailog.Add(objEmailog); } catch (Exception) { throw; } } using (var context = new workorderEMSEntities()) { context.EmailLogs.AddRange(objListEmailog); context.SaveChanges(); } #endregion Email } } else { result = "Somethinsg goes wrong."; } } return(result); } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public MiscellaneousListDetails GetListMiscellaneous(long? UserId,long? Location, int? pageIndex, int? numberOfRows, string sortColumnName, string sortOrderBy, long? locationId, string textSearch, string statusType)", "Exception While Getting List of Miscellaneous details.", null); throw; } }
/// <summary> /// Created By : Ashwajit bansod /// Created Date : 12-OCT-2018 /// Created For : To Save Bill /// </summary> /// <param name="objBillDataServiceModel"></param> /// <returns></returns> public bool SaveBillDetails(BillDataServiceModel objBillDataServiceModel) { bool isBillSaved = false; string Action = ""; string DeliverStatus = ""; var objDAR = new DARModel(); var CommonManager = new CommonMethodManager(); string LocationName = string.Empty; string UserName = string.Empty; try { if (objBillDataServiceModel != null && objBillDataServiceModel.VendorId > 0 && objBillDataServiceModel.LocationId > 0 && objBillDataServiceModel.UserId > 0) { Action = "I"; if (objBillDataServiceModel.PODId > 0) { DeliverStatus = "Y"; var saveBillData = _workorderems.spSetBill(Action, objBillDataServiceModel.QuickBookBillId, objBillDataServiceModel.PODId, null, null, objBillDataServiceModel.VendorId, objBillDataServiceModel.LocationId, objBillDataServiceModel.BillType, objBillDataServiceModel.PoMisBdaAmount, objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, objBillDataServiceModel.UserId, null, DeliverStatus); string[] Quantity = { }; string[] POF = { }; string[] ActiveId = objBillDataServiceModel.IsActive.Split(','); if (objBillDataServiceModel.Quantity != null) { Quantity = objBillDataServiceModel.Quantity.Split(','); } if (objBillDataServiceModel.POF_ID != null) { POF = objBillDataServiceModel.POF_ID.Split(','); } if (objBillDataServiceModel.IsActive != "") { for (int i = 0; i < ActiveId.Length; i++) { if (ActiveId[i] != null) { //ActiveId[i] = "N"; Action = "U"; long POF_ID = Convert.ToInt64(POF[i]); long QantityData = Convert.ToInt64(Quantity[i]); long FacilityId = Convert.ToInt64(ActiveId[i]); DeliverStatus = "N"; var saveFacilityData = _workorderems.spSetPOFacilityItem(Action, POF_ID, objBillDataServiceModel.PODId, FacilityId, QantityData, DeliverStatus); } } } var userData = _workorderems.UserRegistrations.Where(x => x.UserId == objBillDataServiceModel.UserId && x.IsDeleted == false && x.IsEmailVerify == true).FirstOrDefault(); var locationData = _workorderems.LocationMasters.Where(x => x.LocationId == objBillDataServiceModel.LocationId && x.IsDeleted == false).FirstOrDefault(); #region Save DAR LocationName = locationData.LocationServices.ToString(); UserName = userData.FirstName + " " + userData.LastName; objDAR.ActivityDetails = DarMessage.BillCreated(userData.FirstName + "" + userData.LastName, locationData.LocationName, objBillDataServiceModel.PODId); objDAR.TaskType = (long)TaskTypeCategory.BillCreated; objDAR.UserId = objBillDataServiceModel.UserId; objDAR.CreatedBy = objBillDataServiceModel.UserId; objDAR.LocationId = objBillDataServiceModel.LocationId; objDAR.CreatedOn = DateTime.UtcNow; CommonManager.SaveDAR(objDAR); #endregion DAR } else { var savePreBill = _workorderems.spSetPreBill(Action, objBillDataServiceModel.BillNumber, objBillDataServiceModel.LocationId, objBillDataServiceModel.VendorId, objBillDataServiceModel.Comment, objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, objBillDataServiceModel.UserId, null, "N"); if (objBillDataServiceModel.FacilityListForManualBill != null && objBillDataServiceModel.FacilityListForManualBill.Count() > 0) { foreach (var item in objBillDataServiceModel.FacilityListForManualBill) { if (item.UnitPrice > 0) { var saveFacility = _workorderems.spSetBillFacilityItem(Action, null, objBillDataServiceModel.BillNumber, item.COM_FacilityId, item.Quantity, item.UnitPrice, item.Status); } } } //var saveBillData = _workorderems.spSetBill(Action,null, null, null, // objBillDataServiceModel.VendorId, objBillDataServiceModel.LocationId, // objBillDataServiceModel.BillType, null, // objBillDataServiceModel.InvoiceAmount, objBillDataServiceModel.InvoiceDate, objBillDataServiceModel.InvoiceDocument, // objBillDataServiceModel.UserId, null, "Y"); } var objNotify = new NotificationDetailModel(); var _ICommonMethod = new CommonMethodManager(); var objModel = new CommonApproval <ApprovalInput>(); var approvalInput = new ApprovalInput(); approvalInput.Amount = Convert.ToDecimal(objBillDataServiceModel.InvoiceAmount); approvalInput.UserId = objBillDataServiceModel.UserId; approvalInput.ModuleName = "eCounting"; var getRuleData = objModel.GetApprovalRuleData(approvalInput); if (getRuleData != null) { objNotify.CreatedBy = objBillDataServiceModel.UserId; objNotify.CreatedDate = DateTime.UtcNow; objNotify.AssignTo = getRuleData.UserId; if (objBillDataServiceModel.PODId > 0) { objNotify.BillID = objBillDataServiceModel.PODId; } else { objNotify.BillID = objBillDataServiceModel.BillNumber; } var saveDataForNotification = _ICommonMethod.SaveNotificationDetail(objNotify); } if (getRuleData.DeviceId != null) { var objEmailHelper = new EmailHelper(); var objTemplateModel = new TemplateModel(); objEmailHelper.emailid = getRuleData.Email; objEmailHelper.ManagerName = getRuleData.ManagerName; objEmailHelper.LocationName = LocationName; objEmailHelper.UserName = UserName; objEmailHelper.BillId = objNotify.BillID.ToString(); //objEmailHelper.InfractionStatus = obj.Status; objEmailHelper.MailType = "BILLAPPROVE"; objEmailHelper.SentBy = objBillDataServiceModel.UserId; objEmailHelper.LocationID = objDAR.LocationId; objEmailHelper.TimeAttempted = DateTime.UtcNow.ToMobileClientTimeZone(objTemplateModel.TimeZoneName, objTemplateModel.TimeZoneOffset, objTemplateModel.IsTimeZoneinDaylight, false).ToString(); objEmailHelper.IsWorkable = true; string message = PushNotificationMessages.BillCreate(objNotify.BillID.ToString(), objEmailHelper.UserName, objEmailHelper.LocationName); PushNotificationFCM.FCMAndroid(message, getRuleData.DeviceId, objEmailHelper); } isBillSaved = true; } else { isBillSaved = false; } } catch (Exception ex) { Exception_B.Exception_B.exceptionHandel_Runtime(ex, "public BillDataServiceModel SaveBillDetails(BillDataServiceModel objBillDataServiceModel)", "Exception While Saving Bill Details.", null); throw; } return(isBillSaved); }
public Result SaveClientNewUserRegistrationforAll(UserModel objUserModel, out long qrcId, bool IsManagerRegistration, DARModel objDARModel, long locationId, long createdBy, string action) { try { qrcId = 0; ObjUserRepository = new UserRepository(); ObjManagerUser = new UserRegistration(); objGlobalCodesRepository = new GlobalCodesRepository(); if (CheckDuplicateUser(objUserModel.UserEmail.Trim(), objUserModel.UserId, out qrcId, objUserModel.AlternateEmail, objUserModel.EmployeeID)) { objUserModel.IsEmailVerify = true; objUserModel.IsLoginActive = true; objUserModel.SubscriptionEmail = objUserModel.UserEmail; using (TransactionScope TransScope = new TransactionScope()) { if (objUserModel.UserId == 0) { objUserModel.FirstName = objUserModel.FirstName.ToTitleCase(); objUserModel.LastName = objUserModel.LastName.ToTitleCase(); AutoMapper.Mapper.CreateMap <UserModel, UserRegistration>(); string DOB = objUserModel.DOB; objUserModel.DOB = null; ObjManagerUser = AutoMapper.Mapper.Map(objUserModel, ObjManagerUser); ObjManagerUser.ProfileImage = (objUserModel.ProfileImage != null) ? objUserModel.ProfileImageFile : "no-profile-pic.jpg"; if (!string.IsNullOrEmpty(DOB)) { ObjManagerUser.DOB = Convert.ToDateTime(DOB, CultureInfo.InvariantCulture); } ObjManagerUser.IsEmailVerify = false; //added by vijay sahu 12 june 2015 , by default it should not be true ObjManagerUser.IsLoginActive = false; //Added By Bhushan Dod on 04/Sep/2016 for User type of user. ObjManagerUser.UserType = objUserModel.SelectedUserType; ObjUserRepository.Add(ObjManagerUser); if (ObjManagerUser.UserId > 0) { objUserModel.Address.UserId = ObjManagerUser.UserId; objAddressManager.SaveAddress(objUserModel.Address); if (objUserModel.SelectedUserType == Convert.ToInt64(UserType.GlobalAdmin, CultureInfo.InvariantCulture) || objUserModel.SelectedUserType == Convert.ToInt64(UserType.ITAdministrator, CultureInfo.InvariantCulture) || objUserModel.SelectedUserType == Convert.ToInt64(UserType.Administrator, CultureInfo.InvariantCulture) //Commented by Bhushan on 30/05/2016 for no need to check manager bcoz objBB.AssignRoleAndPermission code is doing same // || objUserModel.UserType == Convert.ToInt64(UserType.Manager, CultureInfo.InvariantCulture) ) { _ICommonMethodAdmin.AssignLocationToAdminUser(locationId, ObjManagerUser.UserId); } else if (objUserModel.SelectedUserType == Convert.ToInt64(UserType.Manager, CultureInfo.InvariantCulture)) { _ICommonMethodAdmin.AssignLocationToManagerUser(locationId, ObjManagerUser.UserId); } else if (objUserModel.SelectedUserType == Convert.ToInt64(UserType.Employee, CultureInfo.InvariantCulture)) { _ICommonMethodAdmin.AssignLocationToEmployeeUser(locationId, ObjManagerUser.UserId); } Result objResult = _ICommonMethod.SaveDAR(objDARModel); ////this block is used for assigning roles to the users.. { WorkOrderEMS.BusinessLogic.Managers.Common_B objBB = new WorkOrderEMS.BusinessLogic.Managers.Common_B(); byte a = objBB.AssignRoleAndPermission(ObjManagerUser.UserId, objUserModel.UserType, locationId, createdBy, ""); } if (objUserModel.SelectedServicesID != "" && objUserModel.SelectedServicesID != null && objUserModel.SelectedServicesID.Trim() != "") { GlobalAdminManager ObjGlobalAdminManager = new GlobalAdminManager(); var userServicesID = objUserModel.SelectedServicesID.Split(','); if (userServicesID != null && userServicesID.Length > 0) { foreach (var service in userServicesID) { if (service != null && !string.IsNullOrEmpty(service) && Convert.ToInt64(service, CultureInfo.InvariantCulture) > 0) { long WidgetId = Convert.ToInt64(service, CultureInfo.InvariantCulture); var IsInserted = CommonMethodManager.AddPermissionDetail(WidgetId, ObjManagerUser.UserId, objUserModel.SelectedLocationId.Value); } } //Added By Bhushan Dod on 07/06/2016 for bydefault setting when location created according to loc services. ObjGlobalAdminManager.SaveByDefaultWidgetSetting(locationId, objUserModel.SelectedServicesID, ObjManagerUser.UserId); } } //COMMENTED BY BHUSHAN DOD FOR MULTIPLE ENTRIES INSERTED IN ADMINLOCATIONMAPPING //if (objUserModel.UserType == 6) // only for admin user mapping with location. //{ // _ICommonMethodAdmin.AssignLocationToAdminUser(locationId, ObjManagerUser.UserId); //} //////////////////if (objUserModel.UserType == 3) // only for admin user mapping with location. //////////////////{ ////////////////// using (workorderEMSEntities Context = new workorderEMSEntities()) ////////////////// { ////////////////// EmployeeLocationMappingRepository objmapping = new EmployeeLocationMappingRepository(); ////////////////// objmapping.DeleteAll(x => x.EmployeeUserId == objUserModel.UserId && x.LocationId == locationId); ////////////////// EmployeeLocationMapping MapEntity = new EmployeeLocationMapping(); ////////////////// MapEntity.LocationId = locationId; ////////////////// MapEntity.EmployeeUserId = objUserModel.UserId; ////////////////// MapEntity.ModifiedBy = createdBy; ////////////////// MapEntity.CreatedBy = createdBy; ////////////////// MapEntity.CreatedOn = DateTime.Now; ////////////////// objmapping.Add(MapEntity); ////////////////// objmapping.SaveChanges(); ////////////////// } //////////////////} //_ICommonMethod.GetAdminByIdCode objUserModel.UserId = ObjManagerUser.UserId; TransScope.Complete(); return(Result.Completed); } else { return(Result.Failed); } } else { UpdateUser(objUserModel, out qrcId, IsManagerRegistration); objUserModel.Address.UserId = objUserModel.UserId; objAddressManager.SaveAddress(objUserModel.Address); Result objResult = _ICommonMethod.SaveDAR(objDARModel); TransScope.Complete(); return(Result.UpdatedSuccessfully); } } } else { return(Result.DuplicateRecord); } } catch (Exception) { throw; } }
/// <summary> /// To Delete the User /// </summary> /// <CreatedBy>Manoj Jaswal</CreatedBy> /// <CreatedDate>2015-03-05</CreatedDate> /// <param name="UserId"></param> /// <param name="DeletedBy"></param> public Result DeleteUser(long UserId, long DeletedBy, DARModel objDAR) { long UserType = 0; Result result; long count = 0; try { ObjUserRepository = new UserRepository(); objCommonMethodManager = new CommonMethodManager(); UserRegistration obj_UserRegistration = ObjUserRepository.GetAll(x => x.UserId == UserId).FirstOrDefault(); if (obj_UserRegistration != null) { UserType = obj_UserRegistration.UserType; using (workorderEMSEntities context = new workorderEMSEntities()) { if (UserType == 6) { count = (from o in context.AdminLocationMappings join ur in context.UserRegistrations on o.AdminUserId equals ur.UserId where ur.IsLoginActive == true && ur.IsEmailVerify == true && ur.IsDeleted == false && ur.UserId == UserId && o.IsDeleted == false select o.AdminUserId ).Count(); } else if (UserType == 2) { count = (from o in context.ManagerLocationMappings join ur in context.UserRegistrations on o.ManagerUserId equals ur.UserId where ur.IsLoginActive == true && ur.IsEmailVerify == true && ur.IsDeleted == false && o.IsDeleted == false && ur.UserId == UserId select o.ManagerUserId ).Count(); } } if (count == 0) { obj_UserRegistration.IsDeleted = true; obj_UserRegistration.IsLoginActive = false; obj_UserRegistration.DeletedDate = DateTime.UtcNow; obj_UserRegistration.DeletedBy = DeletedBy; ObjUserRepository.SaveChanges(); objDAR.TaskType = (long)TaskTypeCategory.UserDelete; objDAR.ActivityDetails = DarMessage.UserDeleteDar(obj_UserRegistration.FirstName + ' ' + obj_UserRegistration.LastName); #region Save DAR result = objCommonMethodManager.SaveDAR(objDAR); #endregion Save DAR return(Result.Delete); } else { return(Result.ExistRecord); } } else { return(Result.DoesNotExist); } } catch (Exception ex) { throw ex; } }
/// <summary> /// To Delete the User permanently /// </summary> /// <CreatedBy>Vijay Sahu</CreatedBy> /// <CreatedDate>2015-06-22</CreatedDate> public Tuple <int, string> DeleteUserFromUserList(long UserId, long DeletedBy, DARModel objDAR) { StringBuilder sb = new StringBuilder(); int count = 0; try { ObjUserRepository = new UserRepository(); CommonMethodManager objCommonMethodManager = new CommonMethodManager(); UserRegistration obj_UserRegistration = ObjUserRepository.GetAll(x => x.UserId == UserId).FirstOrDefault(); if (obj_UserRegistration != null) { //UserType = obj_UserRegistration.UserType; workorderEMSEntities Context = new workorderEMSEntities(); List <ssp_DeleteUser_Result> resu = Context.ssp_DeleteUser(UserId, DeletedBy).ToList(); count = Convert.ToInt32(resu.Select(x => x.Result).FirstOrDefault()); if (count == 0) //--SELECT 0,0,0,'There is one or more than one location where he is only one manager' { sb.Append("You can't delete this user because is the only manager for location(s) "); foreach (var locName in resu) { sb.Append("<strong>" + locName.LocationName + "<strong>, "); } try { if (sb.Length > 2 && sb.ToString().Contains(",")) { sb.Remove(sb.Length - 2, 2).Append("."); } } catch { } } else if (count == 1) //--SELECT 1,0,0,'There is no location where he is only one manager' { obj_UserRegistration.IsDeleted = true; obj_UserRegistration.IsLoginActive = false; obj_UserRegistration.DeletedDate = DateTime.UtcNow; obj_UserRegistration.DeletedBy = DeletedBy; ObjUserRepository.SaveChanges(); objDAR.TaskType = (long)TaskTypeCategory.UserDelete; objDAR.ActivityDetails = DarMessage.UserDeleteDar(obj_UserRegistration.FirstName + ' ' + obj_UserRegistration.LastName); #region Save DAR objCommonMethodManager.SaveDAR(objDAR); #endregion Save DAR sb.Clear(); sb.Append(resu.Select(x => x.LocationName).FirstOrDefault() + "."); } else if (count == 2) //--SELECT 2,0,0,'You are not authorised to delete this user' { sb.Clear(); sb.Append(resu.Select(x => x.LocationName).FirstOrDefault() + "."); } } else { sb.Clear(); sb.Append("Please provide proper details for execute delete operation."); } } catch (Exception ex) { throw ex; } Tuple <int, string> returnResult = new Tuple <int, string>(count, sb.ToString()); return(returnResult); }