示例#1
0
        public ActionResult Delete(int ID)
        {
            AccomadationsActionModel model = new AccomadationsActionModel();

            var accomadations = AccomadationsServices.Instance.GetAccomadationsByID(ID); // get accomadations based on ID

            model.ID = accomadations.ID;

            return(PartialView("_Delete", model));
        }
示例#2
0
        // Both 'Action' methods are used for Create and Edit
        public ActionResult Action(int?ID)  // ID can be nullable
        {
            AccomadationsActionModel model = new AccomadationsActionModel();


            if (ID.HasValue) // Editing record
            {
                var accomadations = AccomadationsServices.Instance.GetAccomadationsByID(ID.Value);

                model.ID   = accomadations.ID;
                model.Name = accomadations.Name;
                model.AccomadationPackageID = accomadations.AccomadationPackageID;
            }
            model.AccomadationPackages = AccomadationPackagesService.Instance.GetAllAccomadationPackages();


            return(PartialView("_Action", model));
        }
示例#3
0
        public JsonResult Action(AccomadationsActionModel model)
        {
            JsonResult json = new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            bool result;

            if (model.ID > 0) // Editing record
            {
                Accomadation accomadation = new Accomadation
                {
                    ID   = model.ID,
                    Name = model.Name,
                    AccomadationPackageID = model.AccomadationPackageID
                };

                result = AccomadationsServices.Instance.UpdateAccomadations(accomadation); // update accomadations in databse
            }
            else // Saving record
            {
                Accomadation accomadation = new Accomadation
                {
                    ID   = model.ID,
                    Name = model.Name,
                    AccomadationPackageID = model.AccomadationPackageID
                };

                result = AccomadationsServices.Instance.SaveAccomadations(accomadation); // save accomadations in database
            }


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

            return(json);
        }
示例#4
0
        public JsonResult Delete(AccomadationsActionModel model)
        {
            JsonResult json = new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            var accomadations = AccomadationsServices.Instance.GetAccomadationsByID(model.ID); // get accomadations based on ID passed from model

            var result = AccomadationsServices.Instance.DeleteAccomadations(accomadations);    // delete from database


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

            return(json);
        }