Example #1
0
        public async Task <ActionResult> Manage(int id)
        {
            var model = new PackageHotelCategoryViewModel();

            if (id > 0)
            {
                var record = await this.hotelcategory.GetByIdAsync(id);

                model = this.Mapper.Map <PackageHotelCategoryViewModel>(record);
            }

            return(this.IsAjaxRequest()
                ? this.View("_HotelCategory", model)
                : this.View(model));
        }
Example #2
0
        public async Task <ActionResult> Manage(PackageHotelCategoryViewModel model, string method)
        {
            if (this.ModelState.IsValid)
            {
                var record = this.Mapper.Map <PackageHotelCategoryModel>(model);
                if (model.Id == 0)
                {
                    record.SetAuditInfo(0);
                    await this.hotelcategory.InsertAsync(record);

                    if (!this.IsAjaxRequest())
                    {
                        this.ShowMessage(Messages.SavedSuccessfully);
                    }
                }
                else
                {
                    record.UpdateAuditInfo(0);
                    await this.hotelcategory.UpdateAsync(record);

                    if (!this.IsAjaxRequest())
                    {
                        this.ShowMessage(Messages.UpdateSuccessfully);
                    }
                }

                if (method == "ajax")
                {
                    return(this.Json(new { success = true, Name = model.Name, Id = record.Id.ToString(), Description = model.Description }));
                }

                return(this.RedirectToRoute(Constants.RouteArea, new { controller = "hotelcategory", action = "index", area = Constants.AreaAdmin }));
            }

            return(this.View(model));
        }