public SlotTypeViewModel MapSlotType(SlotType model) { SlotTypeViewModel modelMapping = _mapper.Map <SlotTypeViewModel> (model); modelMapping.SlotViewModels = _mapper.Map <List <SlotViewModel> > (model.Slots); return(modelMapping); }
public SlotTypeViewModel Add(SlotTypeViewModel model) { SlotType modelMapping = _mapper.Map <SlotType> (model); _unitOfWork.SlotTypeRepository.Add(modelMapping); _unitOfWork.SaveChanges(); return(Get(modelMapping.Id)); }
public object Add(SlotTypeViewModel model) { model = _slotTypeService.Add(model); if (model.Id == 0) { return(new ResponseDetails(false, "Could not add new slot type")); } return(new ResponseDetails(true, model)); }
public object Get(int id) { SlotTypeViewModel model = _slotTypeService.Get(id); if (model == null) { return(new ResponseDetails(false, $"Slot type with Id : { id } not found.")); } return(new ResponseDetails(true, model)); }
public IActionResult Create(SlotTypeViewModel model) { if (ModelState.IsValid) { ResponseDetails response = _apiHelper.SendApiRequest(model, "slot-type/add", HttpMethod.Post); if (response.Success) { return(RedirectToAction("Index")); } ErrorViewModel errorModel = new ErrorViewModel() { Message = response.Data.ToString() }; return(View("Error", errorModel)); } ModelState.AddModelError("", "Validation failed"); return(View(model)); }
public void ProtectSlotTypeRouteValues(SlotTypeViewModel model) { model.EncryptedId = _dataProtector.Protect(model.Id.ToString()); }