public Approval GetApprovalRuleData(ApprovalInput data)
        {
            var getRuleData    = new spGetRule_Result();
            var returnRuleData = new Approval();

            try
            {
                if (data.UserId > 0)
                {
                    if (data.ModuleName != null)
                    {
                        getRuleData = _workorderems.spGetRule().Where(x => x.MDL_ModuleName == data.ModuleName &&
                                                                      x.RUL_SlabFrom <= data.Amount && x.RUL_SlabTo >= data.Amount).FirstOrDefault();
                    }
                    //var getManager = _workorderems.spGetManager(data.UserId).FirstOrDefault();
                    if (getRuleData != null)
                    {
                        var getApplyRule = _workorderems.spApplyRule(data.UserId, getRuleData.RUL_MDL_Id, getRuleData.RUL_RuleName
                                                                     , "Amount", data.Amount, null, null).FirstOrDefault();

                        if (getApplyRule != null)
                        {
                            //returnRuleData.CurrentLevel = data.CurrentLevel;
                            returnRuleData.Email       = getApplyRule.UserEmail;
                            returnRuleData.UserId      = Convert.ToInt64(getApplyRule.ApprovedBy);
                            returnRuleData.RuleId      = Convert.ToInt64(getRuleData.RUL_Id);
                            returnRuleData.RuleLevel   = getApplyRule.RUL_Level;
                            returnRuleData.RuleName    = getRuleData.RUL_RuleName;
                            returnRuleData.ManagerName = getApplyRule.FirstName;
                            returnRuleData.DeviceId    = getApplyRule.DeviceId;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(returnRuleData);
        }
Beispiel #2
0
        /// <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;
            }
        }
Beispiel #3
0
        /// <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);
        }