Exemplo n.º 1
0
        public async Task<IHttpActionResult> Put(int id, [FromBody]AppCategorie vM)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var result = await this.categoryService.GetById(id);

            if (result == null)
            {
                return NotFound();
            }
            else
            {
                result.Description = vM.Description;
                result.UpdatedDate = System.DateTime.Now;
                var resultU = await this.categoryService.Update(result);
                if (resultU != 1)
                {
                    return this.StatusCode(HttpStatusCode.BadRequest);
                }
                return this.Ok();
            }
        }
Exemplo n.º 2
0
 public async Task <int> Update(AppCategorie entity)
 {
     using (var rm = new RepositoryManager(new DiscothequeDbEntities()))
     {
         return(await rm.CategoryRespository.Update(entity));
     }
 }
Exemplo n.º 3
0
        public async Task<IHttpActionResult> Create([FromBody]AppCategorie vM)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var dateTime = System.DateTime.Now;

            vM.CreatedBy = "Obtener Usuario Actual";
            vM.CreatedDate = dateTime;
            vM.UpdatedDate = dateTime;

            var resultC = await this.categoryService.Create(vM);
            if (resultC != 1)
            {
                return this.StatusCode(HttpStatusCode.BadRequest);
            }

            //user = Mapper.Map<User, UserViewModel>(_newUser);

            var result = CreatedAtRoute("GetCategory", new { controller = "Category", id = vM.Id }, vM);
            return result;
        }