Esempio n. 1
0
 public Task <TrCaNote> Create(TrCaNote data)
 {
     return(Task.Run(() =>
     {
         TrCaNote trCaNote = _db.TrCaNotes.Add(data);
         _db.SaveChanges();
         return data;
     }));
 }
Esempio n. 2
0
 public Task <TrCaNote> Delete(int id)
 {
     return(Task.Run(() =>
     {
         TrCaNote trCaNote = _db.TrCaNotes.Find(id);
         if (trCaNote != null)
         {
             _db.TrCaNotes.Remove(trCaNote);
             _db.SaveChanges();
         }
         return trCaNote;
     }));
 }
Esempio n. 3
0
 public Task <TrCaNote> UpdateByCreditId(int id, TrCaNote data)
 {
     return(Task.Run(() =>
     {
         TrCaNote trCaNote = _db.TrCaNotes.Where(e => e.CreditApprovalId == id).FirstOrDefault();
         if (trCaNote != null)
         {
             trCaNote.TanggalNota = data.TanggalNota;
             trCaNote.Perihal = data.Perihal;
             trCaNote.Isi = data.Isi;
             trCaNote.UpdatedAt = DateTime.UtcNow;
             _db.SaveChanges();
         }
         return trCaNote;
     }));
 }
Esempio n. 4
0
 public Task <TrCaNote> Update(int id, TrCaNote data)
 {
     return(Task.Run(() =>
     {
         TrCaNote trCaNote = _db.TrCaNotes.Find(id);
         if (trCaNote != null)
         {
             trCaNote.TanggalNota = data.TanggalNota;
             trCaNote.Perihal = data.Perihal;
             trCaNote.Isi = data.Isi;
             trCaNote.UpdatedAt = DateTime.UtcNow;
             _db.SaveChanges();
         }
         return trCaNote;
     }));
 }
        public async Task <IHttpActionResult> Post([FromBody] TrCaNoteRequest data)
        {
            try
            {
                TrCaNote trCaNoteData = data.GetObject();
                trCaNoteData.CreatedBy = GetUserAuth().Name;
                TrCaNote trCaNote = await _trCaNoteRepository.Create(trCaNoteData);

                return(new HttpJsonApiResult <TrCaNoteModel>(
                           new TrCaNoteModel(trCaNote), Request, HttpStatusCode.Created));
            }
            catch (Exception)
            {
                return(new HttpJsonApiResult <string>(
                           "Internal Server Error", Request, HttpStatusCode.InternalServerError));
            }
        }
        public async Task <IHttpActionResult> Update(int id, [FromBody] TrCaNoteRequest data)
        {
            try
            {
                TrCaNote trCaNote = await _trCaNoteRepository.UpdateByCreditId(id, data.GetObject());

                if (trCaNote == null)
                {
                    return(new HttpJsonApiResult <string>("Not Found", Request, HttpStatusCode.NotFound));
                }
                return(new HttpJsonApiResult <TrCaNoteModel>(
                           new TrCaNoteModel(trCaNote), Request, HttpStatusCode.OK));
            }
            catch (Exception)
            {
                return(new HttpJsonApiResult <string>(
                           "Internal Server Error", Request, HttpStatusCode.InternalServerError));
            }
        }
        public async Task <string> UserNotePdf(int id)
        {
            CreditApproval creditApproval = await _creditApprovalRepository.GetOne(id);

            TrCaNote trCaNote = creditApproval.TrCaNotes.FirstOrDefault();
            string   path     = Path.Combine(ConstantValue.FilePath.TemplatePath, ConstantValue.FilePath.UserNotePdf);

            byte[] fileByte = File.ReadAllBytes(path);
            using (MemoryStream memory = new MemoryStream())
            {
                _pdfService.CreateDocumentA4FromMemoryStream(memory);
                _pdfService.ReadPdf(memory, fileByte);
                _pdfService.SetPdfField("Perihal", trCaNote.Perihal);
                _pdfService.SetPdfField("Isi", string.Format("{0}. Demikian disampaikan, atas perhatian dan kerja samanya kami ucapkan terima kasih.", trCaNote.Isi));
                _pdfService.SetPdfField("Jabatan", creditApproval.User.Jabatan);
                _pdfService.SetPdfField("UserName", creditApproval.User.Name);
                _pdfService.ClosePdf();
                return(Convert.ToBase64String(memory.ToArray()));
            }
        }
Esempio n. 8
0
 public TrCaNoteRequest()
 {
     _trCaNote = new TrCaNote();
 }
Esempio n. 9
0
 public TrCaNoteModel()
 {
     _trCaNote = new TrCaNote();
 }
Esempio n. 10
0
 public TrCaNoteModel(TrCaNote trCaNote)
 {
     _trCaNote = trCaNote;
 }