Beispiel #1
0
        public JsonResult ReceiveLocationId(string id)
        {
            int locationId = Int32.Parse(id);

            try
            {
                var     locations   = this.locationService.Get().ToList();
                var     locationVMs = new List <Models.LocationDetailVM>();
                IMapper mapper      = DependencyUtils.Resolve <IMapper>();
                foreach (var item in locations)
                {
                    if (item.LocationID == locationId)
                    {
                        var b = new Models.LocationDetailVM
                        {
                            LocationId  = item.LocationID,
                            BrandId     = item.BrandID,
                            Province    = item.Province,
                            District    = item.District,
                            Address     = item.Address,
                            Description = item.Description
                        };
                        locationVMs.Add(b);
                    }
                }
                return(Json(new
                {
                    locationIdDelete = locationVMs,
                }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public async System.Threading.Tasks.Task <ActionResult> Add(Models.LocationDetailVM model)
        {
            DateTime aDateTime = DateTime.Now;
            var      user      = Helper.GetCurrentUser();

            if (ModelState.IsValid)
            {
                var location = new Data.Models.Entities.Location
                {
                    BrandID        = user.BrandID,
                    Province       = model.Province,
                    District       = model.District,
                    Address        = model.Address,
                    CreateDatetime = aDateTime,
                    Description    = model.Description
                };
                await this.locationService.CreateAsync(location);

                //return this.RedirectToAction("Index");
                Session.Clear();
                Session["ADD_RESULT"] = true;
                return(new ContentResult
                {
                    Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Location")),
                    ContentType = "text/html"
                });
            }
            return(View("Form", model));
        }
Beispiel #3
0
        public async System.Threading.Tasks.Task <ActionResult> Update(Models.LocationDetailVM model)
        {
            var user = Helper.GetCurrentUser();

            if (ModelState.IsValid)
            {
                var location = this.locationService.Get(model.LocationId);
                if (location != null)
                {
                    location.LocationID  = (int)model.LocationId;
                    location.BrandID     = user.BrandID;
                    location.Province    = model.Province;
                    location.District    = model.District;
                    location.Address     = model.Address;
                    location.Description = model.Description;
                }
                await this.locationService.UpdateAsync(location);

                Session.Clear();
                Session["UPDATE_RESULT"] = true;
                return(new ContentResult
                {
                    Content = string.Format("<script type='text/javascript'>window.parent.location.href = '{0}';</script>", Url.Action("Index", "Location")),
                    ContentType = "text/html"
                });
            }
            return(View("Form", model));
        }
Beispiel #4
0
        // GET: Location/Form/:id
        public ActionResult Form(int?id)
        {
            DateTime aDateTime = DateTime.Now;

            Models.LocationDetailVM model        = null;
            IBrandService           brandService = DependencyUtils.Resolve <IBrandService>();

            if (id != null)
            {
                var location = this.locationService.Get(id);
                if (location != null)
                {
                    model = new Models.LocationDetailVM
                    {
                        BrandId     = location.BrandID,
                        LocationId  = location.LocationID,
                        BrandName   = brandService.GetBrandNameByID(location.BrandID),
                        Province    = location.Province,
                        District    = location.District,
                        Address     = location.Address,
                        Description = location.Description,
                        Time        = aDateTime
                    };
                }
            }
            ViewBag.brandList = BrandController.GetBrandList();
            return(View(model));
        }