public HttpResponseMessage SaveIndent(HttpRequestMessage request, IndentHeadViewModel indent) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { var newindentheader = new tbl_indent_header() { tenant_id = indent.tenant_id, indent_no = indent.indent_no, SubContractor_id = indent.SubContractor_id, project_id = indent.project_id, authorized_by = indent.authorized_by, recieved_by = indent.recieved_by, recieved_from = indent.recieved_from, indent_encode = indent.indent_encode, indent_encode_file_type = indent.indent_encode_file_type, date_recieved = indent.date_recieved, date_required = indent.date_required }; for (int i = 0; i < indent.indentdetails.Count; i++) { var newIndentDetails = new tbl_indent_details(); newIndentDetails.AddindentDetails(indent.indentdetails.ToList()[i]); _indentdetailsRepository.Add(newIndentDetails); } var newIndentStatus = new tbl_indentstatus() { indent_id = indent.id, tenant_id = indent.tenant_id, project_id = indent.project_id, indent_no = indent.indent_no, SubContractor_id = indent.SubContractor_id, recieved_by = indent.recieved_by, date_recieved = indent.date_recieved, date_required = indent.date_required, indentstatus = "Created" }; _indentheaderRepository.Add(newindentheader); _indentstatusRepository.Add(newIndentStatus); _unitOfWork.Commit(); response = request.CreateResponse <IndentHeadViewModel>(HttpStatusCode.Created, indent); } return response; })); }
public HttpResponseMessage SaveMaterials(HttpRequestMessage request, IndentDetailsViewModel indent) { return(CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState); } else { tbl_indent_details newProject = new tbl_indent_details(); newProject.AddindentDetails(indent); _indentdetailsRepository.Add(newProject); _unitOfWork.Commit(); response = request.CreateResponse <IndentDetailsViewModel>(HttpStatusCode.Created, indent); } return response; })); }