public async Task <IHttpActionResult> Put(Guid id, [FromBody] MenuAddUpdateViewModel model)
        {
            if (id != model.Id)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(GetModelStateErorrs()));
            }
            var serviceRes = await _menuService.Update(new MenuUpdateRequest()
            {
                RequestOwner = User,
                ViewModel    = model,
                MenuId       = id
            });

            IHttpActionResult res = BadRequest();

            if (serviceRes.Access == ResponseAccess.Granted)
            {
                res = Ok(serviceRes.Menu);
            }
            if (serviceRes.Access == ResponseAccess.Deny)
            {
                res = Unauthorized(serviceRes.Message);
            }

            return(res);
        }
        public async Task <IHttpActionResult> Post(MenuAddUpdateViewModel model)
        {
            var serviceRes = await _menuService.Add(new MenuAddRequest()
            {
                RequestOwner = User,
                ViewModel    = model
            });

            IHttpActionResult res = BadRequest();

            if (serviceRes.Access == ResponseAccess.Granted)
            {
                res = Ok(serviceRes.Menu);
            }
            if (serviceRes.Access == ResponseAccess.Deny)
            {
                res = Unauthorized(serviceRes.Message);
            }

            return(res);
        }
 public static Menu MapToModel(this MenuAddUpdateViewModel menu, Menu existing)
 {
     return(Mapper.Map(menu, existing));
 }
 public static Menu MapToModel(this MenuAddUpdateViewModel menu)
 {
     return(Mapper.Map <Menu>(menu));
 }