Example #1
0
        public string InsertUpdateFollowUp(CustomerExpeditingListViewModel customerObj)
        {
            try
            {
                AppUA _appUA = Session["AppUA"] as AppUA;
                customerObj.followUpObj.commonObj = new CommonViewModel();
                SPAccounts.DataAccessObject.DTO.Common _comonObj = new SPAccounts.DataAccessObject.DTO.Common();
                customerObj.followUpObj.commonObj.CreatedBy   = _appUA.UserName;
                customerObj.followUpObj.commonObj.CreatedDate = _comonObj.GetCurrentDateTime();
                customerObj.followUpObj.commonObj.UpdatedDate = _comonObj.GetCurrentDateTime();
                customerObj.followUpObj.commonObj.UpdatedBy   = _appUA.UserName;
                FollowUpViewModel followupObj = Mapper.Map <FollowUp, FollowUpViewModel>(_paymentFollowupBusiness.InsertUpdateFollowUp(Mapper.Map <FollowUpViewModel, FollowUp>(customerObj.followUpObj)));

                if (customerObj.followUpObj.ID == Guid.Empty)
                {
                    return(JsonConvert.SerializeObject(new { Result = "OK", Records = followupObj, Message = "Insertion successfull" }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new { Result = "OK", Records = followupObj, Message = "Updation successfull" }));
                }
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
 public string InsertUpdateAccountHeadGroup(AccountHeadGroupViewModel accountHeadGroup)
 {
     try
     {
         AppUA appUA = Session["AppUA"] as AppUA;
         accountHeadGroup.commonObj             = new CommonViewModel();
         accountHeadGroup.commonObj.CreatedBy   = appUA.UserName;
         accountHeadGroup.commonObj.CreatedDate = common.GetCurrentDateTime();
         accountHeadGroup.commonObj.UpdatedBy   = appUA.UserName;
         accountHeadGroup.commonObj.UpdatedDate = common.GetCurrentDateTime();
         AccountHeadGroupViewModel CIVM = Mapper.Map <AccountHeadGroup, AccountHeadGroupViewModel>(_accountHeadGroupBusiness.InsertUpdateAccountHeadGroup(Mapper.Map <AccountHeadGroupViewModel, AccountHeadGroup>(accountHeadGroup), appUA));
         if (accountHeadGroup.ID != null && accountHeadGroup.ID != Guid.Empty)
         {
             return(JsonConvert.SerializeObject(new { Result = "OK", Message = c.UpdateSuccess, Records = CIVM }));
         }
         else
         {
             return(JsonConvert.SerializeObject(new { Result = "OK", Message = c.InsertSuccess, Records = CIVM }));
         }
     }
     catch (Exception ex)
     {
         AppConstMessage cm = c.GetMessage(ex.Message);
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
     }
 }
Example #3
0
        public string InsertUpdateOtherExpense(OtherExpenseViewModel otherExpenseViewModel)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //removiing combined code
                    int len = otherExpenseViewModel.AccountCode.IndexOf(':');
                    otherExpenseViewModel.AccountCode = otherExpenseViewModel.AccountCode.Remove(len);
                    //

                    AppUA appUA = Session["AppUA"] as AppUA;
                    otherExpenseViewModel.commonObj = new CommonViewModel();
                    SPAccounts.DataAccessObject.DTO.Common common = new SPAccounts.DataAccessObject.DTO.Common();
                    otherExpenseViewModel.commonObj.CreatedBy   = appUA.UserName;
                    otherExpenseViewModel.commonObj.CreatedDate = common.GetCurrentDateTime();
                    otherExpenseViewModel.commonObj.UpdatedBy   = appUA.UserName;
                    otherExpenseViewModel.commonObj.UpdatedDate = common.GetCurrentDateTime();
                    OtherExpenseViewModel otherExpenseVM = null;

                    switch (otherExpenseViewModel.ID == Guid.Empty)
                    {
                    //INSERT
                    case true:
                        otherExpenseVM = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.InsertOtherExpense(Mapper.Map <OtherExpenseViewModel, OtherExpense>(otherExpenseViewModel)));
                        return(JsonConvert.SerializeObject(new { Result = "OK", Record = otherExpenseVM }));

                    default:
                        //Getting UA
                        otherExpenseVM = Mapper.Map <OtherExpense, OtherExpenseViewModel>(_otherExpenseBusiness.UpdateOtherExpense(Mapper.Map <OtherExpenseViewModel, OtherExpense>(otherExpenseViewModel)));
                        return(JsonConvert.SerializeObject(new { Result = "OK", Record = otherExpenseVM }));
                    }
                }
                catch (Exception ex)
                {
                    return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
                }
            }
            //Model state errror
            else
            {
                List <string> modelErrors = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        modelErrors.Add(modelError.ErrorMessage);
                    }
                }
                return(JsonConvert.SerializeObject(new { Result = "VALIDATION", Message = string.Join(",", modelErrors) }));
            }
        }
Example #4
0
        public string GetDueDate(string Code, string InvDate = "")
        {
            try
            {
                string DuePaymentDueDateFormatted;
                SPAccounts.DataAccessObject.DTO.Common com = new SPAccounts.DataAccessObject.DTO.Common();
                DateTime Datenow = com.GetCurrentDateTime();
                PaymentTermsViewModel payTermsObj = Mapper.Map <PaymentTerms, PaymentTermsViewModel>(_paymentTermsBusiness.GetPayTermDetails(Code));
                if (InvDate == "")
                {
                    DuePaymentDueDateFormatted = Datenow.AddDays(payTermsObj.NoOfDays).ToString("dd-MMM-yyyy");
                }
                else
                {
                    DuePaymentDueDateFormatted = Convert.ToDateTime(InvDate).AddDays(payTermsObj.NoOfDays).ToString("dd-MMM-yyyy");
                }

                return(JsonConvert.SerializeObject(new { Result = "OK", Records = DuePaymentDueDateFormatted }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
Example #5
0
        public string GetInvoicesAndSummary(string filter, string FromDate, string ToDate, string Customer, string InvoiceType, string Company, string Status, string Search)
        {
            try
            {
                AppUA appUA = Session["AppUA"] as AppUA;
                CustomerInvoiceBundleViewModel Result = new CustomerInvoiceBundleViewModel();
                Permission permission       = Session["UserRights"] as Permission;
                string     permissionAccess = permission.SubPermissionList.Where(li => li.Name == "PBAccess").First().AccessCode;

                if (permissionAccess.Contains("R") || permissionAccess.Contains("W"))
                {
                    Result.PBAccess = true;
                }
                else
                {
                    Result.PBAccess = false;
                }

                DateTime?FDate = string.IsNullOrEmpty(FromDate) ? (DateTime?)null : DateTime.Parse(FromDate);
                DateTime?TDate = string.IsNullOrEmpty(ToDate) ? (DateTime?)null : DateTime.Parse(ToDate);
                Result.CustomerInvoiceSummary = Mapper.Map <CustomerInvoiceSummary, CustomerInvoiceSummaryViewModel>(_customerInvoicesBusiness.GetCustomerInvoicesSummaryForSA());
                Result.CustomerInvoices       = Mapper.Map <List <CustomerInvoice>, List <CustomerInvoicesViewModel> >(_customerInvoicesBusiness.GetAllCustomerInvoicesForSA(FDate, TDate, Customer, InvoiceType, Company, Status, Search, Result.PBAccess));


                if (filter != null && filter == "OD")
                {
                    Result.CustomerInvoices = Result.CustomerInvoices.Where(m => m.PaymentDueDate < common.GetCurrentDateTime() && m.BalanceDue > 0).ToList();
                }
                else if (filter != null && filter == "OI")
                {
                    Result.CustomerInvoices = Result.CustomerInvoices.Where(m => m.PaymentDueDate >= common.GetCurrentDateTime() && m.BalanceDue > 0).ToList();
                }
                else if (filter != null && filter == "FP")
                {
                    Result.CustomerInvoices = Result.CustomerInvoices.Where(m => m.BalanceDue <= 0).ToList();
                }

                return(JsonConvert.SerializeObject(new { Result = "OK", Records = Result }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
Example #6
0
 public string GetCustomerPaymentExpeditingDetails(string toDate, string filter, string company, string[] customer, string outstanding, string search)
 {
     try
     {
         AppUA _appUA = Session["AppUA"] as AppUA;
         SPAccounts.DataAccessObject.DTO.Common _comonObj = new SPAccounts.DataAccessObject.DTO.Common();
         DateTime?Date  = _comonObj.GetCurrentDateTime();
         DateTime?TDate = string.IsNullOrEmpty(toDate) ? (DateTime?)null : DateTime.Parse(toDate);
         CustomerExpeditingListViewModel result = new CustomerExpeditingListViewModel();
         result.customerExpeditingDetailsList = Mapper.Map <List <CustomerExpeditingReport>, List <CustomerExpeditingReportViewModel> >(_paymentFollowupBusiness.GetCustomerExpeditingDetail(Date, TDate, filter, company, customer != null ? string.Join(",", customer) : "ALL", outstanding, search));
         return(JsonConvert.SerializeObject(new { Result = "OK", Records = result }));
     }
     catch (Exception ex)
     {
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = ex.Message }));
     }
 }
Example #7
0
 public string UpdateValueInSettings(string Value)
 {
     try
     {
         AppUA appUA = Session["AppUA"] as AppUA;
         SysSettingsViewModel sysSettings = new SysSettingsViewModel();
         sysSettings.Name      = "OE-LIMIT";
         sysSettings.Value     = Value;
         sysSettings.CommonObj = new CommonViewModel();
         SPAccounts.DataAccessObject.DTO.Common common = new SPAccounts.DataAccessObject.DTO.Common();
         sysSettings.CommonObj.UpdatedBy   = appUA.UserName;
         sysSettings.CommonObj.UpdatedDate = common.GetCurrentDateTime();
         string actionMessage = _otherExpenseBusiness.UpdateValueInSettings(Mapper.Map <SysSettingsViewModel, SysSettings>(sysSettings));
         return(JsonConvert.SerializeObject(new { Result = "OK", Message = actionMessage }));
     }
     catch (Exception Ex)
     {
         AppConstMessage cm = c.GetMessage(Ex.Message);
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
     }
 }
Example #8
0
        public string SendNotification(OtherExpenseViewModel otherExpenseVM)
        {
            try
            {
                AppUA appUA = Session["AppUA"] as AppUA;
                SPAccounts.DataAccessObject.DTO.Common common = new SPAccounts.DataAccessObject.DTO.Common();
                otherExpenseVM.commonObj             = new CommonViewModel();
                otherExpenseVM.commonObj.UpdatedBy   = appUA.UserName;
                otherExpenseVM.commonObj.UpdatedDate = common.GetCurrentDateTime();
                bool result = _otherExpenseBusiness.NotifyOtherExpense(otherExpenseVM.ID);

                string  titleString       = "Expense Approval";
                string  descriptionString = otherExpenseVM.RefNo + ", Expense: " + otherExpenseVM.AccountCode + ", Amount: " + otherExpenseVM.Amount + ", Notes: " + otherExpenseVM.Description;
                Boolean isCommon          = true;
                string  customerID        = "";
                _commonBusiness.SendToFCM(titleString, descriptionString, isCommon, customerID);
                return(JsonConvert.SerializeObject(new { Result = "OK", Message = (result ? c.NotificationSuccess : "Failed") }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
Example #9
0
        public string InsertUpdateEmployee(EmployeeViewModel _employeeObj)
        {
            object result = null;

            try
            {
                AppUA appUA = Session["AppUA"] as AppUA;
                _employeeObj.commonObj = new CommonViewModel();
                SPAccounts.DataAccessObject.DTO.Common common = new SPAccounts.DataAccessObject.DTO.Common();
                _employeeObj.commonObj.CreatedBy   = appUA.UserName;
                _employeeObj.commonObj.CreatedDate = appUA.DateTime;
                _employeeObj.commonObj.UpdatedBy   = appUA.UserName;
                _employeeObj.commonObj.UpdatedDate = common.GetCurrentDateTime();
                _employeeObj.IsActive = true;

                result = _employeeBusiness.InsertUpdateEmployee(Mapper.Map <EmployeeViewModel, Employee>(_employeeObj));
                return(JsonConvert.SerializeObject(new { Result = "OK", Records = result }));
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
        public string InsertUpdateSupplier(SuppliersViewModel _supplierObj)
        {
            try
            {
                object result = null;
                AppUA  appUA  = Session["AppUA"] as AppUA;
                _supplierObj.commonObj             = new CommonViewModel();
                _supplierObj.commonObj.CreatedBy   = appUA.UserName;
                _supplierObj.commonObj.CreatedDate = common.GetCurrentDateTime();
                _supplierObj.commonObj.UpdatedBy   = appUA.UserName;
                _supplierObj.commonObj.UpdatedDate = common.GetCurrentDateTime();

                result = _SupplierBusiness.InsertUpdateSupplier(Mapper.Map <SuppliersViewModel, Supplier>(_supplierObj));
                return(JsonConvert.SerializeObject(new { Result = "OK", Records = result }));
                //  string Status = result.GetType().GetProperty("Status").GetValue(result, null).ToString();

                //if (Status == "1")
                //    {

                //    if (_supplierObj.ID == Guid.Empty)
                //    {

                //        string ID = result.GetType().GetProperty("ID").GetValue(result, null).ToString();

                //        string json_data;
                //        string response;

                //        SuppliersAPI supplier = new SuppliersAPI();
                //        supplier.id = ID;
                //        supplier.name = _supplierObj.CompanyName;
                //        supplier.gst_number = _supplierObj.TaxRegNo;
                //        supplier.address = _supplierObj.BillingAddress;
                //        supplier.phone = _supplierObj.LandLine;
                //        supplier.email = _supplierObj.ContactEmail;
                //        supplier.contact_person_name = _supplierObj.ContactPerson;
                //        supplier.contact_person_email = _supplierObj.ContactEmail;
                //        supplier.contact_person_number = _supplierObj.Mobile;


                //        json_data = "{ \"supplier\" :" + JsonConvert.SerializeObject(supplier) + " } ";
                //        response = InvokePostRequest("http://secure.appdeal.in/sp2/rest/web/supplier/save-supplier#", json_data);
                //        ResponseAPI res = new ResponseAPI();
                //        res = JsonConvert.DeserializeObject<ResponseAPI>(response);
                //        if (res.status == "0")
                //        {
                //            result = _SupplierBusiness.DeleteSupplier(ID != null && ID != "" ? Guid.Parse(ID) : Guid.Empty);
                //        }
                //        // dynamic stuff = JsonConvert.DeserializeObject(response);

                //    }
                //    else
                //    {
                //        string json_data;
                //        string response;
                //        string updateID = result.GetType().GetProperty("ID").GetValue(result, null).ToString();
                //        SuppliersAPI supplier = new SuppliersAPI();
                //        supplier.id = updateID;
                //        supplier.name = _supplierObj.CompanyName;
                //        supplier.gst_number = _supplierObj.TaxRegNo;
                //        supplier.address = _supplierObj.BillingAddress;
                //        supplier.phone = _supplierObj.LandLine;
                //        supplier.email = _supplierObj.ContactEmail;
                //        supplier.contact_person_name = _supplierObj.ContactPerson;
                //        supplier.contact_person_email = _supplierObj.ContactEmail;
                //        supplier.contact_person_number = _supplierObj.Mobile;


                //        json_data = "{ \"supplier\" :" + JsonConvert.SerializeObject(supplier) + " } ";
                //        response = InvokePostRequest("http://secure.appdeal.in/sp2/rest/web/supplier/save-supplier#", json_data);


                //    }
                //    }
            }
            catch (Exception ex)
            {
                AppConstMessage cm = c.GetMessage(ex.Message);
                return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
            }
        }
Example #11
0
 public string GetRecentFollowUpCount()
 {
     try
     {
         //AppUA _appUA = Session["AppUAOffice"] as AppUA;
         // DateTime? Date = string.IsNullOrEmpty(_appUA.DateTime) ? (DateTime?)null : DateTime.Parse(Today);
         SPAccounts.DataAccessObject.DTO.Common comonObj = new SPAccounts.DataAccessObject.DTO.Common();
         List <FollowUpViewModel> followupObj            = Mapper.Map <List <FollowUp>, List <FollowUpViewModel> >(_paymentFollowupBusiness.GetRecentFollowUpCount(comonObj.GetCurrentDateTime()));
         return(JsonConvert.SerializeObject(new { Result = "OK", Records = followupObj }));
     }
     catch (Exception ex)
     {
         AppConstMessage cm = c.GetMessage(ex.Message);
         return(JsonConvert.SerializeObject(new { Result = "ERROR", Message = cm.Message }));
     }
 }
Example #12
0
        public void OnAuthentication(AuthenticationContext filterContext)
        {
            //var controllerName = filterContext.RouteData.Values["controller"];
            //var actionName = filterContext.RouteData.Values["action"];
            // if (filterContext.HttpContext.Request.IsAjaxRequest())
            // {
            if ((filterContext.HttpContext.Session == null) || (filterContext.HttpContext.Session["TvmValid"] == null))
            {
                filterContext.Result = new HttpUnauthorizedResult();
                return;
            }
            var authCookie = filterContext.HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie == null)
            {
                // Unauthorized
                filterContext.Result = new HttpUnauthorizedResult();
                return;
            }
            // Get the forms authentication ticket.
            FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);

            if (authTicket == null)
            {
                filterContext.Result = new HttpUnauthorizedResult();     // mark unauthorized*/
            }
            else
            {
                filterContext.HttpContext.User = new System.Security.Principal.GenericPrincipal(
                    new System.Security.Principal.GenericIdentity(authTicket.Name, "Forms"), authTicket.UserData.Split(',').Select(t => t.Trim()).ToArray());


                UA    _ua   = (UA)filterContext.HttpContext.Session["TvmValid"];
                AppUA appUA = new AppUA();
                appUA.RolesCSV = authTicket.UserData;
                appUA.UserName = _ua.UserName;
                LoggedUserName = appUA.UserName;
                SPAccounts.DataAccessObject.DTO.Common common = new SPAccounts.DataAccessObject.DTO.Common();
                appUA.DateTime = common.GetCurrentDateTime();
                appUA.AppID    = _ua.AppID;
                filterContext.HttpContext.Session.Add("AppUA", appUA);
            }
            //}
            //NON AJAX CALL
            //else
            //{

            //    if ((filterContext.HttpContext.Session == null) || (filterContext.HttpContext.Session["TvmValid"] == null))
            //    {
            //        filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary() { { "controller", "Account" }, { "action", "Index" } });
            //        return;
            //    }
            //    ////
            //    var authCookie = filterContext.HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
            //    if (authCookie == null)
            //    {
            //        filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary() { { "controller", "Account" }, { "action", "Index" } });
            //        return;
            //    }
            //    // Get the forms authentication ticket.
            //    FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value);
            //    //  object usercookie = JsonConvert.DeserializeObject(authTicket.UserData); // Up to you to write this Deserialize method -> it should be the reverse of what you did in your Login action
            //    if (authTicket == null)
            //    {
            //        filterContext.Result = new RedirectToRouteResult(new System.Web.Routing.RouteValueDictionary() { { "controller", "Account" }, { "action", "Index" } });
            //    }
            //    else
            //    {

            //        filterContext.HttpContext.User = new System.Security.Principal.GenericPrincipal(
            //        new System.Security.Principal.GenericIdentity(authTicket.Name, "Forms"), authTicket.UserData.Split(',').Select(t => t.Trim()).ToArray());
            //    }
            //}
        }