public MainViewModel.CustomerViewModel GetCustomerDetail(int id) { ResponseMessage resMsg = new ResponseMessage(); try { string query = String.Format("SELECT CustNo ,CustomerName ,CustomerTypeId,MobileNo, Address, Email, PanNo, PostedOn FROM Customer where Cid ={0}", id); MainViewModel.CustomerViewModel returnData = db.Database.SqlQuery <MainViewModel.CustomerViewModel>(query).FirstOrDefault(); if (returnData == null) { var response = this.getMessage(resMsg, HttpStatusCode.PreconditionFailed, false, Logger.JsonDataResult(null)); throw new HttpResponseException(response); } Logger.writeLog(Request, Logger.JsonDataResult(returnData), Logger.JsonDataResult(null)); return(returnData); } catch (Exception ex) { resMsg.message = "Something went wrong. Please try again."; var response = this.getMessage(resMsg, HttpStatusCode.PreconditionFailed, false, Logger.JsonDataResult(null), Logger.JsonDataResult(ex)); throw new HttpResponseException(response); } }
public ActionResult Create(MainViewModel.CustomerViewModel customer) { try { returnMessage = customerService.Save(customer); return(Json(returnMessage, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException ex) { //returnMessage.Msg = "Not Saved" + ex.Message; //return returnMessage; foreach (var eve in ex.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw ex; } }
//[HttpGet] public MainViewModel.CustomerViewModel GetCustomer() { ResponseMessage resMsg = new ResponseMessage(); try { string query = String.Format("select COUNT(*) OVER() AS TotalCount, * from[dbo].[fgetCustomerTB]()"); MainViewModel.CustomerViewModel returnData = db.Database.SqlQuery <MainViewModel.CustomerViewModel>(query).FirstOrDefault(); if (returnData == null) { resMsg.message = "No data found"; var response = this.getMessage(resMsg, HttpStatusCode.PreconditionFailed, false, Logger.JsonDataResult(null)); throw new HttpResponseException(response); } Logger.writeLog(Request, Logger.JsonDataResult(returnData), Logger.JsonDataResult(null)); return(returnData); } catch (Exception ex) { resMsg.message = "Something went wrong. Please try again."; var response = this.getMessage(resMsg, HttpStatusCode.PreconditionFailed, false, Logger.JsonDataResult(null), Logger.JsonDataResult(ex)); throw new HttpResponseException(response); } }
public ActionResult CustomerInfoList(int[] listBox, string mode, string custType, int pageNo = 1, int pageSize = 5) { if (mode == "SubscriptionReport") { MainViewModel.SubscriptionViewModel customerViewModel = new MainViewModel.SubscriptionViewModel(); var suscriberList = customerService.SubscriberInfoList("", "", "", "", 1, 10); customerViewModel.suscriberPagedList = new StaticPagedList <MainViewModel.SubscriptionViewModel>(suscriberList, 1, 10, (suscriberList.Count == 0) ? 0 : suscriberList.FirstOrDefault().TotalCount); //foreach (var item in customerList) //{ // customerViewModel.customerViewModelList.Add(item); //} return(PartialView("~/Views/Suscription/_SubscriptionPopup.cshtml", customerViewModel)); } else { MainViewModel.CustomerViewModel custInfoModel = new MainViewModel.CustomerViewModel(); var custtomerList = customerService.CustomerInfoList("", "", "", custType, pageNo, pageSize); custInfoModel.customerPagedList = new StaticPagedList <MainViewModel.CustomerViewModel>(custtomerList, pageNo, pageSize, (custtomerList.Count == 0) ? 0 : custtomerList.FirstOrDefault().TotalCount); return(PartialView(custInfoModel)); } }
public ActionResult _List(int?customerno, string name, string address, string contact, int?cType, int pageNo = 1, int pageSize = 10) { MainViewModel.CustomerViewModel customerViewModel = new MainViewModel.CustomerViewModel(); var customerList = customerService.getCustomerList(customerno, name, address, contact, cType, 1, pageNo, pageSize); customerViewModel.customerPagedList = new StaticPagedList <MainViewModel.CustomerViewModel>(customerList, pageNo, pageSize, (customerList.Count == 0) ? 0 : customerList.FirstOrDefault().TotalCount); return(PartialView(customerViewModel)); }
public ActionResult Create(int?cId) { MainViewModel.CustomerViewModel customer = new MainViewModel.CustomerViewModel(); if (cId != 0) { customer = customerService.getSingleCustomerList(cId); } return(PartialView(customer)); }
public MainViewModel.CustomerViewModel GetSelectedCustomer(int customerID, string custType) { MainViewModel.CustomerViewModel customerInfoList = new MainViewModel.CustomerViewModel(); customerInfoList = uow.Repository <MainViewModel.CustomerViewModel>().SqlQuery(@"SELECT Cid, CustNo ,CustomerName ,CustomerTypeId,MobileNo ,Address,Email ,PanNo,PostedOn FROM Customer where Cid={0} ", customerID).SingleOrDefault(); return(customerInfoList); }
public ActionResult _CustomerInfoList(string searchParam, string searchOption, string mode, string custType, int pageNo = 1, int pageSize = 5) { if (mode == "SubscriptionReport") { MainViewModel.SubscriptionViewModel customerViewModel = new MainViewModel.SubscriptionViewModel(); var suscriberList = customerService.SubscriberInfoList(searchParam, searchOption, mode, custType, pageNo, pageSize); //if (searchOption != null && searchOption == "Customer Name") //{ // suscriberList = suscriberList.Where(x => x.CustomerName.ToLower().Contains(searchParam.ToLower())).ToList(); //} //if (searchOption != null && searchOption == "Subscription No") //{ // suscriberList = suscriberList.Where(x => x.SubsNo == Convert.ToInt32(searchParam)).ToList(); //} customerViewModel.suscriberPagedList = new StaticPagedList <MainViewModel.SubscriptionViewModel>(suscriberList, pageNo, pageSize, (suscriberList.Count == 0) ? 0 : suscriberList.FirstOrDefault().TotalCount); //foreach (var item in customerList) //{ // customerViewModel.customerViewModelList.Add(item); //} return(PartialView("~/Views/Suscription/_SubscriptionPopupPartial.cshtml", customerViewModel)); } else { MainViewModel.CustomerViewModel custInfoModel = new MainViewModel.CustomerViewModel(); List <MainViewModel.CustomerViewModel> custList = new List <MainViewModel.CustomerViewModel>(); var custtomerList = customerService.CustomerInfoList(searchParam, searchOption, mode, custType, pageNo, pageSize); custInfoModel.customerPagedList = new StaticPagedList <MainViewModel.CustomerViewModel>(custtomerList, pageNo, pageSize, (custtomerList.Count == 0) ? 0 : custtomerList.FirstOrDefault().TotalCount); //if (listBox != null) //{ // foreach (var item in listBox) // { // MainViewModel.CustomerViewModel selectCustInfoModel = new MainViewModel.CustomerViewModel(); // selectCustInfoModel.CID = item; // custList.Add(selectCustInfoModel); // } //} //custInfoModel.SelectedCustInfoList = custList; return(PartialView("_CustomerInfoList", custInfoModel)); } }
public ActionResult List() { try { MainViewModel.CustomerViewModel customerViewModel = new MainViewModel.CustomerViewModel(); var customerList = customerService.getCustomerList(0, "", "", "", null, 1, 1, 10); customerViewModel.customerPagedList = new StaticPagedList <MainViewModel.CustomerViewModel>(customerList, 1, 10, (customerList.Count == 0) ? 0 : customerList.FirstOrDefault().TotalCount); //foreach (var item in customerList) //{ // customerViewModel.customerViewModelList.Add(item); //} return(PartialView(customerViewModel)); } catch (Exception ex) { throw ex; } }
public ReturnBaseMessageModel Save(MainViewModel.CustomerViewModel customer) { try { if (customer.PanNo == null) { customer.PanNo = "0"; } uow.ExecWithStoreProcedure("[dbo].[PCreateCustomer] @Cid,@CustomerName,@CustomerTypeId,@PhoneNo,@MobileNo,@Address,@Email,@PanNo,@PostedBy", new SqlParameter("@Cid", customer.Cid), new SqlParameter("@CustomerName", customer.CustomerName), new SqlParameter("@CustomerTypeId", customer.CustomerTypeId), new SqlParameter("@PhoneNo", customer.PhoneNo), new SqlParameter("@MobileNo", customer.MobileNo), new SqlParameter("@Address", customer.Address), new SqlParameter("@Email", customer.Email), new SqlParameter("@PanNo", customer.PanNo), new SqlParameter("@PostedBy", Global.UserId) ); if (customer.Cid == 0) { returnMessage.Msg = "Customer Added Sucessfully"; } else { returnMessage.Msg = "Customer Edited Sucessfully"; } returnMessage.Success = true; return(returnMessage); } catch (Exception ex) { returnMessage.Msg = "Customer Not Saved"; returnMessage.Success = false; return(returnMessage); throw ex; } }
public FileContentResult CustomerExportToExcel(int?customerno, string name, string address, string contact, int?cType, string cTypetext = "", int status = 1, string statustext = "", int pageNo = 1, int pageSize = 0) { MainViewModel.CustomerViewModel customerViewModel = new MainViewModel.CustomerViewModel(); var customerList = customerService.getCustomerList(customerno, name, address, contact, cType, status, pageNo, pageSize); var customerExcelList = customerList.Select(x => new ExcelViewModel.CustomerExcelViewModel() { CustNo = x.CustNo, CustomerName = x.CustomerName, Email = x.Email, PhoneNo = x.PhoneNo, MobileNo = x.MobileNo, Customertype = x.Customertype, Address = x.Address }).ToList(); if (cTypetext == "--Select Event--") { cTypetext = ""; } string[] columns = { "Customer No.", "Customer Name", "Customer Type", "Phone No.", "Mobile No", "Address", "Email", "Status" }; string[] parameterSearch = { "Customer No.:" + customerno, "Customer Name:" + name, "Address:" + address, "Mobile No:" + contact, "Customer Type:" + cTypetext, "Status:" + statustext }; byte[] fileContent = ExcelExportHelper.ExportExcel(customerExcelList, parameterSearch, null, "Customer Report", columns); return(File(fileContent, ExcelExportHelper.ExcelContentType, "Customer Report.xlsx")); }
public ActionResult DisplayQRCode(int?cId) { MainViewModel.CustomerViewModel customer = new MainViewModel.CustomerViewModel(); customer = customerService.getSingleCustomerList(cId); return(PartialView(customer)); }