Beispiel #1
0
        public JsonResult Action(Accomodation model, bool isDeleted = false)
        {
            JsonResult json   = new JsonResult();
            var        result = false;

            if (model.Id > 0 && isDeleted == false)
            {
                //edit here
                result = accomodationService.UpdateAccomodations(model);
            }
            else if (model.Id > 0 && isDeleted == true)
            {
                //delete here
                result = accomodationService.DeleteAccomodations(model.Id);
            }

            else
            {
                //first create object then add
                Accomodation accomodation = new Accomodation();

                accomodation.AccomodationPackageId = model.AccomodationPackageId;
                accomodation.Name        = model.Name;
                accomodation.Description = model.Description;


                result = accomodationService.SaveAccomodations(accomodation);
            }

            if (result)
            {
                json.Data = new { success = true };
            }
            else
            {
                json.Data = new { success = false, Messag = "Unable to Perform Operation." };
            }

            return(json);
        }
        public JsonResult Action(AccomodationActionViewModel model)
        {
            JsonResult jsonResult = new JsonResult();
            var        result     = false;

            if (model.Id > 0)
            {
                var accomodation = accomodationService.GetAccomodationsById(model.Id);

                accomodation.AccomodationName      = model.AccomodationName;
                accomodation.Description           = model.Description;
                accomodation.AccomodationPackageId = model.AccomodationPackageId;

                result = accomodationService.UpdateAccomodations(accomodation);
            }
            else
            {
                Accomodation newRecord = new Accomodation();

                newRecord.AccomodationName      = model.AccomodationName;
                newRecord.Description           = model.Description;
                newRecord.AccomodationPackageId = model.AccomodationPackageId;

                result = accomodationService.SaveAccomodations(newRecord);
            }

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

            return(jsonResult);
        }