Exemplo n.º 1
0
 // Add new item
 public Employee AddEmployee(EmployeeAdd Employee)
 {
     // Map from DTO object to domain (POCO) object
     var p = ds.Employees.Add(Mapper.Map<ICTGWS.Models.Employee>(Employee));  //<=====
     ds.SaveChanges();
     // Map to DTO object
     return Mapper.Map<Employee>(p);
 }
Exemplo n.º 2
0
        public HttpResponseMessage PostEmp(EmployeeAdd employee)
        {
            if (ModelState.IsValid)
            {
                // Add the new item
                var c = r.AddEmployee(employee);

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, employee);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = employee.EmployeeId }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }