Ejemplo n.º 1
0
            public async Task<HttpResponseMessage> Update(int id, EmployeeModel model)
            
            {
                try
                {
                    int result = await service.UpdateAsync(Mapper.Map<IEmployee>(model));

                    if (result >= 1)
                    {
                        return Request.CreateResponse(HttpStatusCode.OK, model);
                    }
                    else
                    {
                        return Request.CreateResponse(HttpStatusCode.BadRequest, "Error while trying to edit task.");
                    }
                }
                catch (Exception ex)
                {
                    return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
                }
            }
Ejemplo n.º 2
0
            public async Task<HttpResponseMessage> Insert(EmployeeModel emp)
            {
                try
                {
                    int result = await service.AddAsync(Mapper.Map<IEmployee>(emp));

                    if (result == 0)
                    {
                        return Request.CreateResponse(HttpStatusCode.BadRequest, "Add operation error.");
                    }

                    else
                    {
                        return Request.CreateResponse(HttpStatusCode.OK, result);
                    }
                }
                catch (Exception ex)
                {

                    return Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
                }
            }