public ActionResult Create(TaxiServiceModel model) { GetSelectListData(); if (ModelState.IsValid) { try { model.CreatedBy = GetUser().UserId; model.CreatedOn = DateTime.UtcNow; Mapper.CreateMap<TaxiServiceModel, TaxiServiceEntity>(); TaxiServiceEntity service = Mapper.Map<TaxiServiceEntity>(model); TaxiServiceModel addedService = TaxiRepository.CreateTaxiService(service); if (addedService != null) { return RedirectToAction("Index", new { message = MessageType.Success }); } ViewBag.MessageType = MessageType.Error; ViewBag.Message = "Unable to create service, Error occurred"; return View("Create", model); } catch (TaxiServiceExistsException e) { ViewBag.MessageType = MessageType.Error; ViewBag.Message = e.Message; return View(model); } catch (Exception) { throw; } } return View(model); }
public ActionResult Delete(TaxiServiceModel service) { try { bool status = TaxiRepository.DeleteTaxiService(service.ServiceId); if (!status) return RedirectToAction("Index", new { message = MessageType.Error }); return RedirectToAction("Index", new { message = MessageType.Success }); } catch (TaxiServiceNotFoundException) { throw; } catch (Exception) { throw; } }
public ActionResult Edit(TaxiServiceModel model) { try { if (ModelState.IsValid) { model.UpdatedOn = DateTime.UtcNow; model.UpdatedBy = GetUser().UserId; Mapper.CreateMap<TaxiServiceModel, TaxiServiceEntity>(); TaxiServiceEntity entity = Mapper.Map<TaxiServiceEntity>(model); TaxiServiceModel updatedService = TaxiRepository.UpdateTaxiService(entity); if (updatedService != null) // return RedirectToAction("Tours", new { message = MessageType.Success }); return RedirectToAction("Index", new { message = MessageType.Success }); ViewBag.MessageType = MessageType.Error; ViewBag.Message = "Unable to update service, error occurred"; return View(model); } return View(model); } catch (TaxiServiceExistsException e) { ViewBag.MessageType = MessageType.Error; ViewBag.Message = e.Message; return View(model); } catch (Exception) { throw; } }