Ejemplo n.º 1
0
        public ActionResult Delete(int ID)
        {
            ImportantShoppingActionModel model = new ImportantShoppingActionModel();

            var importantShopping = importantShoppingService.GetImportantShoppingsByID(ID);

            model.ID = importantShopping.ID;

            return(PartialView("_Delete", model));
        }
Ejemplo n.º 2
0
        public JsonResult Action(ImportantShoppingActionModel model)
        {
            JsonResult json = new JsonResult();

            var result = false;

            //model.PictureIDs = "90,67,23" = ["90", "67", "23"] = {90, 67, 23}
            List <int> pictureIDs = !string.IsNullOrEmpty(model.PictureIDs) ? model.PictureIDs.Split(',').Select(x => int.Parse(x)).ToList() : new List <int>();
            var        pictures   = dashboardService.GetPicturesByIDs(pictureIDs);

            if (model.ID > 0) //we are trying to edit a record
            {
                var importantShopping = importantShoppingService.GetImportantShoppingsByID(model.ID);

                importantShopping.Name = model.Name;

                importantShopping.Price     = model.Price;
                importantShopping.Place     = model.Place;
                importantShopping.DateStart = model.DateStart;
                importantShopping.DateStop  = model.DateStop;

                importantShopping.ShoppingPictures.Clear();
                importantShopping.ShoppingPictures.AddRange(pictures.Select(x => new ShoppingPicture()
                {
                    ImportantShoppingID = importantShopping.ID, PictureID = x.ID
                }));


                result = importantShoppingService.UpdateImportantShoppings(importantShopping);
            }
            else     //we are trying to create a record
            {
                ImportantShopping importantShopping = new ImportantShopping();

                importantShopping.Name = model.Name;

                importantShopping.Price     = model.Price;
                importantShopping.Place     = model.Place;
                importantShopping.DateStart = model.DateStart;
                importantShopping.DateStop  = model.DateStop;

                result = importantShoppingService.SaveImportantShoppings(importantShopping);
            }

            if (result)
            {
                json.Data = new { Success = true };
            }
            else
            {
                json.Data = new { Success = false, Message = "Unable to perform action on Debt." };
            }

            return(json);
        }
Ejemplo n.º 3
0
        public ActionResult Action(int?ID)
        {
            ImportantShoppingActionModel model = new ImportantShoppingActionModel();

            if (ID.HasValue)     //we are trying to edit a record
            {
                var importantShopping = importantShoppingService.GetImportantShoppingsByID(ID.Value);

                model.ID = importantShopping.ID;

                model.Name      = importantShopping.Name;
                model.Place     = importantShopping.Place;
                model.Price     = importantShopping.Price;
                model.DateStart = importantShopping.DateStop;

                model.ShoppingPictures = importantShoppingService.GetPicturesByImportantShoppingID(importantShopping.ID);
            }

            return(PartialView("_Action", model));
        }
Ejemplo n.º 4
0
        public JsonResult Delete(ImportantShoppingActionModel model)
        {
            JsonResult json = new JsonResult();

            var result = false;

            var importantShopping = importantShoppingService.GetImportantShoppingsByID(model.ID);

            result = importantShoppingService.DeleteImportantShoppings(importantShopping);

            if (result)
            {
                json.Data = new { Success = true };
            }
            else
            {
                json.Data = new { Success = false, Message = "Unable to perform action on Debts." };
            }

            return(json);
        }