private static CustomerSite getEntityByModel(CustomerSiteModel model) { if (model == null) { return(null); } CustomerSite entity = new CustomerSite(); if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; } entity.CodeCombinationId = model.CodeCombinationId; entity.CustomerId = model.CustomerId; entity.EndDate = model.EndDate; entity.Id = model.Id; entity.SiteAddress = model.SiteAddress; entity.SiteContact = model.SiteContact; entity.SiteName = model.SiteName; entity.StartDate = model.StartDate; entity.TaxCodeId = model.TaxId; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return(entity); }
public JsonResult CheckDate(DateTime invoiceDate, long periodId, long customerId, long customerSiteId) { bool result = false; if (periodId > 0) { if (SessionHelper.Calendar != null) { if (invoiceDate >= SessionHelper.Calendar.StartDate && invoiceDate <= SessionHelper.Calendar.EndDate) { result = true; } } } if (customerId > 0) { CustomerModel customer = CustomerHelper.GetCustomer(customerId.ToString()); if (customer.StartDate == null || invoiceDate >= customer.StartDate) { result = true; } else { result = false; } if (customer.EndDate == null || invoiceDate <= customer.EndDate) { result = true; } else { result = false; } //if (invoiceDate >= customer.StartDate && invoiceDate <= customer.EndDate) // result = true; //else // result = false; } if (customerSiteId > 0) { CustomerSiteModel customerSite = CustomerHelper.GetCustomerSite(customerSiteId.ToString()); if (invoiceDate >= customerSite.StartDate && invoiceDate <= customerSite.EndDate) { result = true; } else { result = false; } } return(Json(result)); }
public static string SaveCustomerSite(CustomerSiteModel model) { if (model.Id > 0) { return(siteService.Update(getEntityByModel(model))); } else { return(siteService.Insert(getEntityByModel(model))); } }
public ActionResult Edit(long customerId, long?id) { ViewBag.CustomerName = CustomerHelper.GetCustomer(customerId.ToString()).CustomerName; CustomerSiteModel model; if (id != null) { model = CustomerHelper.GetCustomerSite(id.Value.ToString()); CodeCombinitionCreateViewModel codeCombination = CodeCombinationHelper.GetCodeCombination(model.CodeCombinationId.ToString()); model.CodeCombinationString = Utility.Stringize(".", codeCombination.Segment1, codeCombination.Segment2, codeCombination.Segment3, codeCombination.Segment4, codeCombination.Segment5, codeCombination.Segment6, codeCombination.Segment7, codeCombination.Segment8); } else { model = new CustomerSiteModel(); model.CustomerId = customerId; } model.TaxCode = taxService.GetAll(AuthenticationHelper.CompanyId.Value) .Select(x => new SelectListItem { Text = x.TaxName, Value = x.Id.ToString() }).ToList(); model.TaxId = model.TaxCode.Any() ? Convert.ToInt64(model.TaxCode.First().Value) : 0; //model.CodeCombination = codeCombinationService.GetAllCodeCombinitionView(AuthenticationHelper.CompanyId.Value) // .Select(x => new SelectListItem // { // Text = x.CodeCombinitionCode, // Value = x.Id.ToString() // }).ToList(); //model.CodeCombinationId = model.CodeCombination.Any() ? Convert.ToInt64(model.CodeCombination.First().Value) : 0; return(View(model)); }
public ActionResult Edit(string id, long currencyId, long periodId) { InvoiceModel model = InvoiceHelper.GetInvoice(id); SessionHelper.Calendar = CalendarHelper.GetCalendar(ReceivablePeriodHelper.GetReceivablePeriod(periodId.ToString()).CalendarId.ToString()); SessionHelper.PrecisionLimit = CurrencyHelper.GetCurrency(currencyId.ToString()).Precision; model.InvoiceDetail = InvoiceHelper.GetInvoiceDetail(id); model.CurrencyId = currencyId; model.SOBId = SessionHelper.SOBId; model.PeriodId = periodId; CustomerModel customer = CustomerHelper.GetCustomer(model.CustomerId.ToString()); CustomerSiteModel customerSite = CustomerHelper.GetCustomerSite(model.CustomerSiteId.ToString()); ///TODO: Plz check the code. model.Customers = new List <SelectListItem>(); model.Customers.Add(new SelectListItem { Value = customer.Id.ToString(), Text = customer.CustomerName }); model.CustomerSites = new List <SelectListItem>(); model.CustomerSites.Add(new SelectListItem { Value = customerSite.Id.ToString(), Text = customerSite.SiteName }); model.Currencies = CurrencyHelper.GetCurrencyList(SessionHelper.SOBId); //model.Periods = CalendarHelper.GetCalendarsList(SessionHelper.SOBId); model.Periods = ReceivablePeriodHelper.GetPeriodList(SessionHelper.SOBId); SessionHelper.Invoice = model; return(View(model)); }
public ActionResult Edit(CustomerSiteModel model) { if (ModelState.IsValid) { try { string result = ""; CustomerModel customer = CustomerHelper.GetCustomer(model.CustomerId.ToString()); if ((model.StartDate >= customer.StartDate && model.EndDate <= customer.EndDate) || (model.StartDate == null && customer.StartDate == null || model.EndDate == null && customer.EndDate == null)) { result = CustomerHelper.SaveCustomerSite(model); return(RedirectToAction("Index", new { Id = model.CustomerId })); } else { ModelState.AddModelError("Error", "Site Dates should be within the range of Customer Dates."); } } catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); } } model.TaxCode = taxService.GetAll(AuthenticationHelper.CompanyId.Value) .Select(x => new SelectListItem { Text = x.TaxName, Value = x.Id.ToString() }).ToList(); model.TaxId = model.TaxCode.Any() ? Convert.ToInt64(model.TaxCode.First().Value) : 0; return(View(model)); }
public static CustomerSiteModel GetCustomerSite(string customerSiteId) { CustomerSiteModel customerSite = new CustomerSiteModel(siteService.GetSingle(customerSiteId, AuthenticationHelper.CompanyId.Value)); return(customerSite); }