public async Task <IActionResult> GetBillOfmaterialAndFinalizeAsync([FromRoute] int id) { IncentiveBoMRequestItem incentiveBoMRequestItem = _context.IncentiveBoMRequestItem.First(p => p.IncentiveBoMRequestItemId == id); if (incentiveBoMRequestItem.IsApproved) { incentiveBoMRequestItem.IsApproved = false; _context.Entry(incentiveBoMRequestItem).State = EntityState.Modified; } else { incentiveBoMRequestItem.IsApproved = true; _context.Entry(incentiveBoMRequestItem).State = EntityState.Modified; ServiceApplication serviceApplication = _context.ServiceApplication.First(p => p.ServiceApplicationId == incentiveBoMRequestItem.ServiceApplicationId); serviceApplication.IsActive = true; serviceApplication.EndDate = DateTime.Now; serviceApplication.CurrentStatusId = 44447; _context.Entry(serviceApplication).State = EntityState.Modified; ServiceWorkflowHistory serviceWorkflowHistory = new ServiceWorkflowHistory(); serviceWorkflowHistory.ActionId = 3; serviceWorkflowHistory.StepId = 8; serviceWorkflowHistory.FromStatusId = 3; serviceWorkflowHistory.ToStatusId = 3; serviceWorkflowHistory.PerformedByRoleId = 3; serviceWorkflowHistory.NextStepId = 9; serviceWorkflowHistory.ServiceId = 1040; serviceWorkflowHistory.LegalStatusId = 3; serviceWorkflowHistory.CreatedUserId = 1; serviceWorkflowHistory.IsActive = true; serviceWorkflowHistory.ServiceApplicationId = incentiveBoMRequestItem.ServiceApplicationId; _context.ServiceWorkflowHistories.Add(serviceWorkflowHistory); } try { await _context.SaveChangesAsync(); return(CreatedAtAction("GetIncentiveBoMRequestItem", incentiveBoMRequestItem)); } catch (DbUpdateConcurrencyException) { if (!IncentiveBoMRequestItemExists(id)) { return(NotFound()); } else { throw; } } }
public async Task <IActionResult> PostIncentiveBoMRequestItem([FromBody] IncentiveBoMRequestItem incentiveBoMRequestItem) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} _context.IncentiveBoMRequestItem.Add(incentiveBoMRequestItem); await _context.SaveChangesAsync(); return(CreatedAtAction("GetIncentiveBoMRequestItem", new { id = incentiveBoMRequestItem.IncentiveBoMRequestItemId }, incentiveBoMRequestItem)); }
public async Task <IncentiveBoMRequestItem> PutIncentiveBoMRequestItem([FromRoute] int id, [FromBody] IncentiveBoMRequestItem incentiveBoMRequestItem) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} //if (id != incentiveBoMRequestItem.IncentiveBoMRequestItemId) //{ // return BadRequest(); //} if (incentiveBoMRequestItem.RejectionReason != null) { incentiveBoMRequestItem.IsApproved = false; } _context.Entry(incentiveBoMRequestItem).State = EntityState.Modified; try { await _context.SaveChangesAsync(); //return incentiveBoMRequestItem; } catch (DbUpdateConcurrencyException) { //if (!IncentiveBoMRequestItemExists(id)) //{ // return NotFound(); //} //else //{ // throw; //} } return(incentiveBoMRequestItem); //return NoContent(); }