public List <ServiceLocationModel> GetServiceLocations() { try { List <ServiceLocationModel> serviceLocations = new List <ServiceLocationModel>(); var data = _trs.ServiceLocationMasters.Where(x => x.isActive == true).ToList(); foreach (var item in data) { ServiceLocationModel db = new ServiceLocationModel { Id = item.Id, servicelocationcode = item.servicelocationcode, servicelocationname = item.servicelocationname, defaultdeliverytype = item.defaultdeliverytype, controllingbranch = item.controllingbranch, deliveryat = item.deliveryat, distancefrombranch = item.distancefrombranch, istodaybooking = item.istodaybooking, pickupcharges = item.pickupcharges, DDCharges = item.DDCharges, controllingbranchname = _trs.BranchMasters.Where(x => x.id == item.controllingbranch).Select(x => x.branchName).FirstOrDefault(), deliveryatname = _trs.BranchMasters.Where(x => x.id == item.deliveryat).Select(x => x.branchName).FirstOrDefault(), }; serviceLocations.Add(db); } return(serviceLocations); } catch (Exception e) { throw e; } }
public ServiceLocationModel GetServiceLocation(int id) { try { var check = _trs.ServiceLocationMasters.Where(x => x.Id == id && x.isActive == true).FirstOrDefault(); if (check != null) { ServiceLocationModel db = new ServiceLocationModel() { Id = check.Id, servicelocationcode = check.servicelocationcode, servicelocationname = check.servicelocationname, defaultdeliverytype = check.defaultdeliverytype, controllingbranch = check.controllingbranch, deliveryat = check.deliveryat, distancefrombranch = check.distancefrombranch, istodaybooking = check.istodaybooking, pickupcharges = check.pickupcharges, DDCharges = check.DDCharges, }; return(db); } return(null); } catch (Exception e) { throw e; } }
public bool SaveServiceLocation(ServiceLocationModel model) { try { ServiceLocationMaster db = new ServiceLocationMaster() { isActive = true, servicelocationcode = model.servicelocationcode, servicelocationname = model.servicelocationname, defaultdeliverytype = model.defaultdeliverytype, controllingbranch = model.controllingbranch, deliveryat = model.deliveryat, distancefrombranch = model.distancefrombranch, istodaybooking = model.istodaybooking, pickupcharges = model.pickupcharges, DDCharges = model.DDCharges, }; _trs.ServiceLocationMasters.Add(db); _trs.SaveChanges(); return(true); } catch (Exception e) { throw e; } }
public bool UpdateServiceLocation(ServiceLocationModel model) { try { var check = _trs.ServiceLocationMasters.Where(x => x.Id == model.Id && x.isActive == true).FirstOrDefault(); if (check != null) { check.servicelocationcode = model.servicelocationcode; check.servicelocationname = model.servicelocationname; check.defaultdeliverytype = model.defaultdeliverytype; check.controllingbranch = model.controllingbranch; check.deliveryat = model.deliveryat; check.distancefrombranch = model.distancefrombranch; check.istodaybooking = model.istodaybooking; check.pickupcharges = model.pickupcharges; check.DDCharges = model.DDCharges; _trs.SaveChanges(); return(true); } return(false); } catch (Exception e) { throw e; } }
public ActionResult saveUpdateLocation(ServiceLocationModel model) { try { return(Json(new { result = 1, ID = model.SaveUpdateServiceLocation(model) }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { error = ex.Message }, JsonRequestBehavior.AllowGet)); } }
// // GET: /ServiceLocations/Edit/5 public ActionResult Edit(int id) { ServiceLocationBAL _serviceLocationBAL = new ServiceLocationBAL(); ServiceLocation _serviceLocation = _serviceLocationBAL.GetServiceLocationById(id); var model = new ServiceLocationModel(); model.Id = _serviceLocation.Id; model.Location = _serviceLocation.Location; model.City = _serviceLocation.City; model.State = _serviceLocation.State; model.Country = _serviceLocation.Country; model.Zipcode = _serviceLocation.Zipcode; model.IpAddress = _serviceLocation.IpAddress; _serviceLocationBAL.UpdateServiceLocation(_serviceLocation); return(View(model)); }
public ActionResult Index() { ServiceLocationBAL _serviceLocationBAL = new ServiceLocationBAL(); List <ServiceLocation> _serviceLocation = _serviceLocationBAL.GetAllLocation(); List <ServiceLocationModel> _serviceLocationModel = new List <ServiceLocationModel>(); foreach (var s in _serviceLocation) { var model = new ServiceLocationModel(); model.Id = s.Id; model.Location = s.Location; model.State = s.State; model.City = s.City; model.Country = s.Country; model.Zipcode = s.Zipcode; model.IpAddress = s.IpAddress; _serviceLocationModel.Add(model); } return(View(_serviceLocationModel)); }
public ActionResult Edit(int id, ServiceLocationModel serviceLocation) { try { // TODO: Add update logic here ServiceLocationBAL serviceLocationBAL = new ServiceLocationBAL(); ServiceLocation _serviceLocation = serviceLocationBAL.GetServiceLocationById(id); _serviceLocation.Id = serviceLocation.Id; _serviceLocation.Location = serviceLocation.Location; _serviceLocation.City = serviceLocation.City; _serviceLocation.State = serviceLocation.State; _serviceLocation.Country = serviceLocation.Country; _serviceLocation.Zipcode = serviceLocation.Zipcode; _serviceLocation.IpAddress = serviceLocation.IpAddress; serviceLocationBAL.UpdateServiceLocation(_serviceLocation); return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(ServiceLocationModel serviceLocation) { try { // TODO: Add insert logic here ServiceLocation _serviceLocation = new ServiceLocation(); _serviceLocation.Id = serviceLocation.Id; _serviceLocation.Location = serviceLocation.Location; _serviceLocation.City = serviceLocation.City; _serviceLocation.State = serviceLocation.State; _serviceLocation.Country = serviceLocation.Country; _serviceLocation.Zipcode = serviceLocation.Zipcode; _serviceLocation.IpAddress = serviceLocation.IpAddress; ServiceLocationBAL _serviceLocationBAL = new ServiceLocationBAL(); _serviceLocationBAL.AddServiceLocation(_serviceLocation); return(RedirectToAction("Index")); } catch { return(View()); } }
public IHttpActionResult UpdateServiceLocation(ServiceLocationModel model) { var data = serviceLocationRepo.UpdateServiceLocation(model); return(Ok(data)); }