public async Task <IHttpActionResult> Approve(int id, [FromBody] ActionNoteRequest actionNoteRequest)
        {
            try
            {
                EUserRole     userRole = GetUserAuth().UserRole;
                UserModel     getUser  = GetUserAuth();
                EStatusCredit statusCredit;

                if (userRole == EUserRole.User)
                {
                    statusCredit = EStatusCredit.AR;
                }
                else if (userRole == EUserRole.AR)
                {
                    statusCredit = EStatusCredit.CashBank;
                }
                else if (userRole == EUserRole.CashBank)
                {
                    statusCredit = EStatusCredit.FBS;
                }
                else if (userRole == EUserRole.FBS)
                {
                    statusCredit = EStatusCredit.ManagementRisk;
                }
                else if (userRole == EUserRole.ManagementRisk)
                {
                    statusCredit = EStatusCredit.KomiteCredit;
                }
                else
                {
                    statusCredit = EStatusCredit.Completed;
                }


                CreditApproval creditApproval = await _creditApprovalRepository.UpdateStatus(id, statusCredit, true);

                if (creditApproval == null)
                {
                    return(new HttpJsonApiResult <string>("Not Found", Request, HttpStatusCode.NotFound));
                }

                TrCaActionNote trCaActionNote = await _trCaActionNoteRepository.Create(new TrCaActionNote()
                {
                    CreditApprovalId = creditApproval.Id,
                    ActionNote       = actionNoteRequest.ActionNote,
                    ActionType       = 1,
                    ActionBy         = getUser.Id
                });

                //send email here
                return(new HttpJsonApiResult <CreditApprovalModel>(new CreditApprovalModel(creditApproval),
                                                                   Request, HttpStatusCode.OK));
            }
            catch (Exception)
            {
                return(new HttpJsonApiResult <string>(
                           "Internal Server Error", Request, HttpStatusCode.InternalServerError));
            }
        }
 public Task <TrCaActionNote> Create(TrCaActionNote data)
 {
     return(Task.Run(() =>
     {
         TrCaActionNote trCaActionNote = _db.TrCaActionNotes.Add(data);
         _db.SaveChanges();
         return trCaActionNote;
     }));
 }
 public Task <TrCaActionNote> Delete(int id)
 {
     return(Task.Run(() =>
     {
         TrCaActionNote trCaActionNote = _db.TrCaActionNotes.Find(id);
         if (trCaActionNote != null)
         {
             _db.TrCaActionNotes.Remove(trCaActionNote);
             _db.SaveChanges();
         }
         return trCaActionNote;
     }));
 }
 public Task <TrCaActionNote> Update(int id, TrCaActionNote data)
 {
     return(Task.Run(() =>
     {
         TrCaActionNote trCaActionNote = _db.TrCaActionNotes.Find(id);
         if (trCaActionNote != null)
         {
             trCaActionNote.ActionNote = data.ActionNote;
             trCaActionNote.ActionType = data.ActionType;
             trCaActionNote.ActionBy = data.ActionBy;
             trCaActionNote.UpdatedAt = DateTime.UtcNow;
             _db.SaveChanges();
         }
         return trCaActionNote;
     }));
 }
Beispiel #5
0
 public ActionNoteRequest()
 {
     _trCaActionNote = new TrCaActionNote();
 }