Beispiel #1
0
        public async Task <IHttpActionResult> Put([FromUri] Guid id, CategoryAddOrUpdateViewModel model)
        {
            IHttpActionResult res = BadRequest();

            if (id != model.Id)
            {
                return(res);
            }

            var serviceRes = await _categoryService.Update(new CategoryUpdateRequest()
            {
                RequestOwner = User,
                ViewModel    = model,
                Id           = id
            });

            if (serviceRes.Access == ResponseAccess.Granted)
            {
                res = Ok(serviceRes.Category);
            }
            if (serviceRes.Access == ResponseAccess.Deny)
            {
                res = Unauthorized(serviceRes.Message);
            }
            return(res);
        }
Beispiel #2
0
        public async Task <IHttpActionResult> Post(CategoryAddOrUpdateViewModel model)
        {
            IHttpActionResult res = BadRequest();
            var serviceRes        = await _categoryService.Add(new CategoryAddRequest()
            {
                RequestOwner = User,
                Model        = model
            });

            if (serviceRes.Access == ResponseAccess.Granted)
            {
                res = Ok(serviceRes.Category);
            }
            if (serviceRes.Access == ResponseAccess.Deny)
            {
                res = Unauthorized(serviceRes.Message);
            }
            return(res);
        }
 public static void MapToExisting(this CategoryAddOrUpdateViewModel viewModel, Category category)
 {
     Mapper.Map(viewModel, category);
 }
 public static Category MapToModel(this CategoryAddOrUpdateViewModel category)
 {
     return(Mapper.Map <Category>(category));
 }