public async Task <IActionResult> Update(CategoryBookingViewModel model, string saveCommand = null) { if (!ModelState.IsValid) { return(View("CategoryBookingForm", model)); } var entity = new CategoryBooking(); _mapper.Map(model, entity); var response = await HttpRequestFactory.Put(Constants.BaseApiUrl + "CategoryBooking/" + model.Id, entity); var outmodel = response.ContentAsType <SingleModelResponse <CategoryBooking> >(); if (outmodel.DidError || !response.IsSuccessStatusCode) { ViewBag.ErrorMsg = outmodel.ErrorMessage ?? response.ReasonPhrase; return(View("CategoryBookingForm", model)); } AlertShow(); if (saveCommand != Constants.SaveContinute) { return(RedirectToAction("Index")); } model = _mapper.Map(outmodel.Model, model); return(RedirectToAction("Edit", new { id = model.Id })); }
public async Task <IActionResult> Edit(int id) { var outputModel = await GetSingle(id); var model = new CategoryBookingViewModel(); _mapper.Map(outputModel.Model, model); return(View("CategoryBookingForm", model)); }
public IActionResult Create() { var model = new CategoryBookingViewModel(); return(View("CategoryBookingForm", model)); }