Example #1
0
        public IHttpActionResult UpdateCoverNote([FromBody] JObject data)
        {
            try
            {
                CoverNoteVM coverNoteObj = data.SelectToken("CoverNoteObj").ToObject <CoverNoteVM>();
                int         userID       = !string.IsNullOrEmpty(data.SelectToken("UserID").Value <string>()) ? Convert.ToInt32(data.SelectToken("UserID").Value <string>()) : 0;

                coverNoteObj.ModifiedBy = userID;

                bool status = manageCoverNote.UpdateCoverNote(coverNoteObj);

                if (status)
                {
                    return(Json(new { status = true, message = "Successfully Updated" }));
                }
                else
                {
                    return(Json(new { status = false, message = "Update Failed" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { status = false, message = "Unknown error occurred" }));
            }
        }
        public List <CoverNoteVM> GetCoverByQuotationID(int quotationID)
        {
            try
            {
                var coverNoteData = unitOfWork.TblCoverNoteRepository.Get(x => x.QuotationHeaderID == quotationID).ToList();

                List <CoverNoteVM> coverNote = new List <CoverNoteVM>();
                foreach (var covernote in coverNoteData)
                {
                    CoverNoteVM coverNoteVM = new CoverNoteVM();
                    coverNoteVM.CoverNoteID       = covernote.CoverNoteID;
                    coverNoteVM.QuotationHeaderID = covernote.QuotationHeaderID != null?Convert.ToInt32(covernote.QuotationHeaderID) : 0;

                    coverNoteVM.InsuranceSubClassID = covernote.InsSubClassID != null?Convert.ToInt32(covernote.InsSubClassID) : 0;

                    if (coverNoteVM.InsuranceSubClassID > 0)
                    {
                        coverNoteVM.InsuranceSubClassName = covernote.tblInsSubClass.Description;
                    }
                    coverNoteVM.CoverNoteNo        = covernote.CoverNoteNo;
                    coverNoteVM.ConfirmationMethod = covernote.ConfirmationMethod;
                    coverNoteVM.PendingDocItem     = covernote.PendingDocItem;
                    coverNoteVM.FromDate           = covernote.FromDate != null?covernote.FromDate.ToString() : string.Empty;

                    coverNoteVM.ToDate = covernote.ToDate != null?covernote.ToDate.ToString() : string.Empty;

                    coverNoteVM.IssuedDate = covernote.IssuedDate != null?covernote.IssuedDate.ToString() : string.Empty;

                    coverNoteVM.CreatedBy = covernote.CreatedBy != null?Convert.ToInt32(covernote.CreatedBy) : 0;

                    coverNoteVM.CreatedDate = covernote.CreatedDate != null?covernote.CreatedDate.ToString() : string.Empty;

                    coverNoteVM.ModifiedBy = covernote.ModifiedBy != null?Convert.ToInt32(covernote.ModifiedBy) : 0;

                    coverNoteVM.ModifiedDate = covernote.ModifiedDate != null?covernote.ModifiedDate.ToString() : string.Empty;

                    coverNote.Add(coverNoteVM);
                }
                //CoverNoteVM coverNoteVM = new CoverNoteVM();


                //if (coverNoteVM.InsuranceSubClassID > 0)
                //{
                //    coverNoteVM.InsuranceSubClassName = coverNoteData.tblInsSubClass.Description;
                //}



                return(coverNote);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool UpdateCoverNote(CoverNoteVM coverNoteVM)
        {
            using (var dbTransaction = unitOfWork.dbContext.Database.BeginTransaction())
            {
                try
                {
                    tblCoverNote coverNote = unitOfWork.TblCoverNoteRepository.GetByID(coverNoteVM.CoverNoteID);
                    coverNote.QuotationHeaderID  = coverNoteVM.QuotationHeaderID;
                    coverNote.InsSubClassID      = coverNoteVM.InsuranceSubClassID;
                    coverNote.CoverNoteNo        = coverNoteVM.CoverNoteNo;
                    coverNote.ConfirmationMethod = coverNoteVM.ConfirmationMethod;
                    coverNote.PendingDocItem     = coverNoteVM.PendingDocItem;
                    coverNote.FromDate           = !string.IsNullOrEmpty(coverNoteVM.FromDate) ? DateTime.ParseExact(coverNoteVM.FromDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                    coverNote.ToDate             = !string.IsNullOrEmpty(coverNoteVM.ToDate) ? DateTime.ParseExact(coverNoteVM.ToDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                    coverNote.IssuedDate         = !string.IsNullOrEmpty(coverNoteVM.IssuedDate) ? DateTime.ParseExact(coverNoteVM.IssuedDate, "MM/dd/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                    coverNote.ModifiedDate       = DateTime.Now;
                    coverNote.ModifiedBy         = coverNoteVM.ModifiedBy;
                    unitOfWork.TblCoverNoteRepository.Update(coverNote);
                    unitOfWork.Save();

                    //Update Quotation Status Code
                    tblQuotationHeader quotationHeader = unitOfWork.TblQuotationHeaderRepository.GetByID(coverNoteVM.QuotationHeaderID);

                    if (quotationHeader.QuotationStatusCode != QuotationStatusCodeEnum.TCNI.ToString())
                    {
                        quotationHeader.QuotationStatusCode = QuotationStatusCodeEnum.TCNI.ToString();
                        unitOfWork.TblQuotationHeaderRepository.Update(quotationHeader);
                        unitOfWork.Save();
                    }

                    //Complete the Transaction
                    dbTransaction.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    //Roll back the Transaction
                    dbTransaction.Rollback();
                    return(false);
                }
            }
        }
        public CoverNoteVM GetCoverNoteByID(int coverNoteID)
        {
            try
            {
                var coverNoteData = unitOfWork.TblCoverNoteRepository.GetByID(coverNoteID);

                CoverNoteVM coverNoteVM = new CoverNoteVM();
                coverNoteVM.CoverNoteID       = coverNoteData.CoverNoteID;
                coverNoteVM.QuotationHeaderID = coverNoteData.QuotationHeaderID != null?Convert.ToInt32(coverNoteData.QuotationHeaderID) : 0;

                coverNoteVM.InsuranceSubClassID = coverNoteData.InsSubClassID != null?Convert.ToInt32(coverNoteData.InsSubClassID) : 0;

                if (coverNoteVM.InsuranceSubClassID > 0)
                {
                    coverNoteVM.InsuranceSubClassName = coverNoteData.tblInsSubClass.Description;
                }

                coverNoteVM.CoverNoteNo        = coverNoteData.CoverNoteNo;
                coverNoteVM.ConfirmationMethod = coverNoteData.ConfirmationMethod;
                coverNoteVM.PendingDocItem     = coverNoteData.PendingDocItem;
                coverNoteVM.FromDate           = coverNoteData.FromDate != null?coverNoteData.FromDate.ToString() : string.Empty;

                coverNoteVM.ToDate = coverNoteData.ToDate != null?coverNoteData.ToDate.ToString() : string.Empty;

                coverNoteVM.IssuedDate = coverNoteData.IssuedDate != null?coverNoteData.IssuedDate.ToString() : string.Empty;

                coverNoteVM.CreatedBy = coverNoteData.CreatedBy != null?Convert.ToInt32(coverNoteData.CreatedBy) : 0;

                coverNoteVM.CreatedDate = coverNoteData.CreatedDate != null?coverNoteData.CreatedDate.ToString() : string.Empty;

                coverNoteVM.ModifiedBy = coverNoteData.ModifiedBy != null?Convert.ToInt32(coverNoteData.ModifiedBy) : 0;

                coverNoteVM.ModifiedDate = coverNoteData.ModifiedDate != null?coverNoteData.ModifiedDate.ToString() : string.Empty;

                return(coverNoteVM);
            }
            catch (Exception ex)
            {
                throw;
            }
        }