// PUT api/EmployeeInfoAPI/5 public HttpResponseMessage PutEmployeeInfo(int id, EmployeeInfo employeeinfo) { if (!ModelState.IsValid) { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } if (id != employeeinfo.EmpNo) { return Request.CreateResponse(HttpStatusCode.BadRequest); } db.EmployeeInfoes.Attach(employeeinfo); db.ObjectStateManager.ChangeObjectState(employeeinfo, EntityState.Modified); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException ex) { return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex); } return Request.CreateResponse(HttpStatusCode.OK); }
// POST api/EmployeeInfoAPI public HttpResponseMessage PostEmployeeInfo(EmployeeInfo employeeinfo) { if (ModelState.IsValid) { db.EmployeeInfoes.AddObject(employeeinfo); db.SaveChanges(); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, employeeinfo); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = employeeinfo.EmpNo })); return response; } else { return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } }
/// <summary> /// Deprecated Method for adding a new object to the EmployeeInfoes EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToEmployeeInfoes(EmployeeInfo employeeInfo) { base.AddObject("EmployeeInfoes", employeeInfo); }
/// <summary> /// Create a new EmployeeInfo object. /// </summary> /// <param name="empNo">Initial value of the EmpNo property.</param> /// <param name="empName">Initial value of the EmpName property.</param> /// <param name="salary">Initial value of the Salary property.</param> /// <param name="deptName">Initial value of the DeptName property.</param> /// <param name="designation">Initial value of the Designation property.</param> public static EmployeeInfo CreateEmployeeInfo(global::System.Int32 empNo, global::System.String empName, global::System.Decimal salary, global::System.String deptName, global::System.String designation) { EmployeeInfo employeeInfo = new EmployeeInfo(); employeeInfo.EmpNo = empNo; employeeInfo.EmpName = empName; employeeInfo.Salary = salary; employeeInfo.DeptName = deptName; employeeInfo.Designation = designation; return employeeInfo; }