示例#1
0
        public SlotTypeViewModel MapSlotType(SlotType model)
        {
            SlotTypeViewModel modelMapping = _mapper.Map <SlotTypeViewModel> (model);

            modelMapping.SlotViewModels = _mapper.Map <List <SlotViewModel> > (model.Slots);

            return(modelMapping);
        }
示例#2
0
        public SlotTypeViewModel Add(SlotTypeViewModel model)
        {
            SlotType modelMapping = _mapper.Map <SlotType> (model);

            _unitOfWork.SlotTypeRepository.Add(modelMapping);
            _unitOfWork.SaveChanges();

            return(Get(modelMapping.Id));
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
 public void ProtectSlotTypeRouteValues(SlotTypeViewModel model)
 {
     model.EncryptedId = _dataProtector.Protect(model.Id.ToString());
 }