Exemplo n.º 1
0
 public MobileApiController(IUserService us,
                            IPolicyInsuredService pis,
                            IAdditionalChargesService acs,
                            IPolicyService ps,
                            IFirstNoticeOfLossService fnls,
                            IHealthInsuranceService his,
                            ILuggageInsuranceService lis,
                            IOkSetupService oss,
                            IBankAccountService bas,
                            IInsuredsService iss,
                            IFirstNoticeOfLossService fis,
                            IPolicyTypeService pts,
                            IAdditionalInfoService ais,
                            ICountryService coun,
                            IExchangeRateService exch,
                            IFranchiseService fran,
                            ITravelNumberService tn,
                            IOkSetupService os)
 {
     _ps   = ps;
     _us   = us;
     _fnls = fnls;
     _lis  = lis;
     _oss  = oss;
     _his  = his;
     _bas  = bas;
     _iss  = iss;
     _fis  = fis;
     _pts  = pts;
     _ais  = ais;
     _pis  = pis;
     _acs  = acs;
     _coun = coun;
     _exch = exch;
     _fran = fran;
     _tn   = tn;
     _os   = os;
 }
 public FirstNoticeOfLossController(IUserService us,
                                    IPolicyService ps,
                                    IPolicyInsuredService pis,
                                    IInsuredsService iss,
                                    IFirstNoticeOfLossService fis,
                                    IBankAccountService bas,
                                    IPolicyTypeService pts,
                                    IAdditionalInfoService ais,
                                    IHealthInsuranceService his,
                                    ILuggageInsuranceService lis,
                                    IFirstNoticeOfLossArchiveService firstNoticeLossArchiveService)
 {
     _us  = us;
     _ps  = ps;
     _pis = pis;
     _iss = iss;
     _bas = bas;
     _pts = pts;
     _ais = ais;
     _fis = fis;
     _his = his;
     _lis = lis;
     _firstNoticeLossArchiveService = firstNoticeLossArchiveService;
 }
        public static int  SaveDetailFirstNoticeOdLoss(DetailFirstNoticeOfLossViewModel addDetailLoss,
                                                       travel_policy policy,
                                                       IFirstNoticeOfLossService _fis,
                                                       IAdditionalInfoService _ais,
                                                       IBankAccountService _bas)
        {
            try
            {
                var loss = _fis.Create();
                loss.PolicyId   = policy.ID;
                loss.ClaimantId = addDetailLoss.Claimant_ID;
                loss.Relation_claimant_policy_holder = addDetailLoss.RelationClaimantPolicyHolder;
                loss.Destination       = addDetailLoss.Destination;
                loss.Depart_Date_Time  = addDetailLoss.Depart_Date_Time;
                loss.Arrival_Date_Time = addDetailLoss.Arrival_Date_Time;
                loss.Transport_means   = addDetailLoss.Transport_means;
                loss.Total_cost        = addDetailLoss.Total_cost;
                loss.CreatedDateTime   = DateTime.UtcNow;
                loss.FNOL_Number       = _fis.CreateFNOLNumber();

                //loss.Message = "";
                loss.CreatedBy = addDetailLoss.CreatedBy;

                //additional info
                var additionalInfo = _ais.Create();
                additionalInfo.Accident_place    = addDetailLoss.Accident_place;
                additionalInfo.Datetime_accident = addDetailLoss.Datetime_accident;
                var additionalInfoID = _ais.Add(additionalInfo);
                loss.Additional_infoID = additionalInfoID;

                //bank accounts for policy holder
                var holderBankAccountsExist = _bas.CheckIfBankAccountExist(addDetailLoss.Policy_HolderID, addDetailLoss.PolicyHolder_BankAccount, addDetailLoss.PolicyHolder_BankID);
                if (!holderBankAccountsExist)
                {
                    var bankAccount = new bank_account_info();
                    bankAccount.Account_HolderID = addDetailLoss.Policy_HolderID;
                    bankAccount.BankID           = addDetailLoss.PolicyHolder_BankID;
                    bankAccount.Account_Number   = addDetailLoss.PolicyHolder_BankAccount;
                    var policyHolerBankAccount = _bas.AddBankAccountInfo(bankAccount);
                    loss.Policy_holder_bank_accountID = policyHolerBankAccount;
                }
                else
                {
                    var policyHolderBankAccount = _bas.GetBankAccountInfo(addDetailLoss.Policy_HolderID, addDetailLoss.PolicyHolder_BankAccount, addDetailLoss.PolicyHolder_BankID);
                    loss.Policy_holder_bank_accountID = policyHolderBankAccount.ID;
                }

                //bank accounts for claimant
                var claimantBankAccountsExist = _bas.CheckIfBankAccountExist(addDetailLoss.Claimant_ID, addDetailLoss.Claimant_BankAccount, addDetailLoss.Claimant_BankID);
                if (!claimantBankAccountsExist)
                {
                    var bankAccount = new bank_account_info();
                    bankAccount.Account_HolderID = addDetailLoss.Claimant_ID;
                    bankAccount.BankID           = addDetailLoss.Claimant_BankID;
                    bankAccount.Account_Number   = addDetailLoss.Claimant_BankAccount;
                    var claimantBankAccount = _bas.AddBankAccountInfo(bankAccount);
                    loss.Claimant_bank_accountID = claimantBankAccount;
                }
                else
                {
                    var claimantBankAccount = _bas.GetBankAccountInfo(addDetailLoss.Claimant_ID, addDetailLoss.Claimant_BankAccount, addDetailLoss.Claimant_BankID);
                    loss.Claimant_bank_accountID = claimantBankAccount.ID;
                }

                var lossID = _fis.Add(loss);

                if (addDetailLoss.HealthInsurance_Y_N.Equals("Y"))
                {
                    var healthInsuranceInfo = new health_insurance_info
                    {
                        Additional_infoId        = additionalInfoID,
                        additional_info          = additionalInfo,
                        Datetime_doctor_visit    = addDetailLoss.Datetime_doctor_visit,
                        Doctor_info              = addDetailLoss.Doctor_info,
                        Medical_case_description = addDetailLoss.Medical_case_description,
                        Previous_medical_history = addDetailLoss.Previous_medical_history,
                        Responsible_institution  = addDetailLoss.Responsible_institution
                    };

                    _ais.AddHealthInsuranceInfo(healthInsuranceInfo);
                }
                else if (addDetailLoss.LuggageInsurance_Y_N.Equals("Y"))
                {
                    float floaterValue = 0;
                    float.TryParse(addDetailLoss.Floaters_value, out floaterValue);
                    var luggageInsuranceInfo = new luggage_insurance_info
                    {
                        Additional_infoId     = additionalInfoID,
                        additional_info       = additionalInfo,
                        Place_description     = addDetailLoss.Place_description,
                        Detail_description    = addDetailLoss.Detail_description,
                        Report_place          = addDetailLoss.Report_place,
                        Floaters              = addDetailLoss.Floaters,
                        Floaters_value        = floaterValue,
                        Luggage_checking_Time = addDetailLoss.Luggage_checking_Time ?? new TimeSpan(0, 0, 0)
                    };

                    _ais.AddLuggageInsuranceInfo(luggageInsuranceInfo);
                }
                return(lossID);
            }
            catch (Exception e)
            {
                return(-1);
            }
        }
        public static int SaveFirstNoticeOfLoss(IInsuredsService _iss, IUserService _us, IFirstNoticeOfLossService _fis,
                                                IBankAccountService _bas, IPolicyTypeService _pts, IAdditionalInfoService _ais,
                                                FirstNoticeOfLossReportViewModel firstNoticeOfLossViewModel, IEnumerable <HttpPostedFileBase> invoices,
                                                IEnumerable <HttpPostedFileBase> documentsHealth, IEnumerable <HttpPostedFileBase> documentsLuggage)
        {
            var result         = -1;
            var additionalInfo = _ais.Create();

            if (firstNoticeOfLossViewModel.IsHealthInsurance)
            {
                additionalInfo.Accident_place = firstNoticeOfLossViewModel.AccidentPlaceHealth;
                if (firstNoticeOfLossViewModel.AccidentDateTimeHealth != null)
                {
                    var      dateTime = firstNoticeOfLossViewModel.AccidentDateTimeHealth.Value;
                    var      timeSpan = firstNoticeOfLossViewModel.AccidentTimeHealth.Value;
                    DateTime d        = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day);
                    d.Add(timeSpan);
                    additionalInfo.Datetime_accident = d;
                }
                var healthInsuranceInfo = new health_insurance_info
                {
                    Additional_infoId        = _ais.Add(additionalInfo),
                    additional_info          = additionalInfo,
                    Datetime_doctor_visit    = firstNoticeOfLossViewModel.DoctorVisitDateTime,
                    Doctor_info              = firstNoticeOfLossViewModel.DoctorInfo,
                    Medical_case_description = firstNoticeOfLossViewModel.MedicalCaseDescription,
                    Previous_medical_history = firstNoticeOfLossViewModel.PreviousMedicalHistory,
                    Responsible_institution  = firstNoticeOfLossViewModel.ResponsibleInstitution
                };

                try
                {
                    _ais.AddHealthInsuranceInfo(healthInsuranceInfo);
                }
                finally { }
            }
            else
            {
                additionalInfo.Accident_place = firstNoticeOfLossViewModel.AccidentPlaceLuggage;
                if (firstNoticeOfLossViewModel.AccidentDateTimeLuggage != null)
                {
                    var      dateTime = firstNoticeOfLossViewModel.AccidentDateTimeLuggage.Value;
                    var      timeSpan = firstNoticeOfLossViewModel.AccidentTimeLuggage.Value;
                    DateTime d        = new DateTime(dateTime.Year, dateTime.Month, dateTime.Day);
                    additionalInfo.Datetime_accident = d + timeSpan;
                }
                var luggageInsuranceInfo = new luggage_insurance_info
                {
                    Additional_infoId     = _ais.Add(additionalInfo),
                    additional_info       = additionalInfo,
                    Place_description     = firstNoticeOfLossViewModel.PlaceDescription,
                    Detail_description    = firstNoticeOfLossViewModel.DetailDescription,
                    Report_place          = firstNoticeOfLossViewModel.ReportPlace,
                    Floaters              = firstNoticeOfLossViewModel.Floaters,
                    Floaters_value        = float.Parse(firstNoticeOfLossViewModel.FloatersValue),
                    Luggage_checking_Time = firstNoticeOfLossViewModel.LugaggeCheckingTime ?? new TimeSpan(0, 0, 0)
                };

                try
                {
                    _ais.AddLuggageInsuranceInfo(luggageInsuranceInfo);
                }
                finally { }
            }
            var firstNoticeOfLossEntity = _fis.Create();

            firstNoticeOfLossEntity.PolicyId   = firstNoticeOfLossViewModel.PolicyId;
            firstNoticeOfLossEntity.ClaimantId = firstNoticeOfLossViewModel.ClaimantId;
            firstNoticeOfLossEntity.Relation_claimant_policy_holder = firstNoticeOfLossViewModel.RelationClaimantPolicyHolder;
            firstNoticeOfLossEntity.Destination       = firstNoticeOfLossViewModel.Destination;
            firstNoticeOfLossEntity.Depart_Date_Time  = firstNoticeOfLossViewModel.DepartDateTime;
            firstNoticeOfLossEntity.Arrival_Date_Time = firstNoticeOfLossViewModel.ArrivalDateTime;
            firstNoticeOfLossEntity.Transport_means   = firstNoticeOfLossViewModel.TransportMeans;
            firstNoticeOfLossEntity.Total_cost        = firstNoticeOfLossViewModel.TotalCost;
            firstNoticeOfLossEntity.CreatedDateTime   = DateTime.Now;
            firstNoticeOfLossEntity.FNOL_Number       = _fis.CreateFNOLNumber();

            string username;

            if (firstNoticeOfLossViewModel.isMobile)
            {
                username = firstNoticeOfLossViewModel.username;
            }
            else
            {
                username = System.Web.HttpContext.Current.User.Identity.Name;
            }
            firstNoticeOfLossEntity.CreatedBy = _us.GetUserIdByUsername(username);
            //firstNoticeOfLossEntity.Message = "";
            firstNoticeOfLossEntity.Additional_infoID = additionalInfo.ID;
            firstNoticeOfLossEntity.PolicyId          = firstNoticeOfLossViewModel.PolicyId;
            firstNoticeOfLossEntity.ClaimantId        = firstNoticeOfLossEntity.ClaimantId;
            firstNoticeOfLossEntity.Relation_claimant_policy_holder = firstNoticeOfLossEntity.Relation_claimant_policy_holder;

            if (!firstNoticeOfLossViewModel.isMobile && firstNoticeOfLossViewModel.ClaimantExistentBankAccount)
            {
                firstNoticeOfLossEntity.Claimant_bank_accountID = firstNoticeOfLossViewModel.ClaimantForeignBankAccountId;
            }
            else
            {
                var bankAccountId = SaveBankAccountInfoHelper.SaveBankAccountInfo(_bas, firstNoticeOfLossViewModel.ClaimantId,
                                                                                  firstNoticeOfLossViewModel.ClaimantBankName,
                                                                                  firstNoticeOfLossViewModel.ClaimantBankAccountNumber);

                firstNoticeOfLossEntity.Claimant_bank_accountID = bankAccountId;
            }

            if (firstNoticeOfLossViewModel.PolicyHolderExistentBankAccount)
            {
                firstNoticeOfLossEntity.Policy_holder_bank_accountID = firstNoticeOfLossViewModel.PolicyHolderForeignBankAccountId;
            }
            else
            {
                var bankAccountId = SaveBankAccountInfoHelper.SaveBankAccountInfo(_bas, firstNoticeOfLossViewModel.PolicyHolderId,
                                                                                  firstNoticeOfLossViewModel.PolicyHolderBankName,
                                                                                  firstNoticeOfLossViewModel.PolicyHolderBankAccountNumber);

                firstNoticeOfLossEntity.Policy_holder_bank_accountID = bankAccountId;
            }

            int FirstNoticeOfLossID = 0;

            try
            {
                FirstNoticeOfLossID = _fis.Add(firstNoticeOfLossEntity);
            }

            finally { }
            var lastDocumentId = _fis.LastDocumentId();

            if (invoices != null)
            {
                foreach (var file in invoices)
                {
                    lastDocumentId++;
                    if (file != null && file.ContentLength > 0)
                    {
                        string fileName = file.FileName + "_" + FirstNoticeOfLossID + "_" + lastDocumentId;
                        var    path     = @"~/DocumentsFirstNoticeOfLoss/Invoices/" + fileName;
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));

                        var document = new document();
                        document.Name = fileName;
                        var documentID = _fis.AddDocument(document);
                        _fis.AddInvoice(documentID);
                        _fis.AddDocumentToFirstNoticeOfLoss(documentID, FirstNoticeOfLossID);
                    }
                }
            }

            if (documentsHealth != null)
            {
                foreach (var file in documentsHealth)
                {
                    lastDocumentId++;
                    if (file != null && file.ContentLength > 0)
                    {
                        string fileName = file.FileName + "_" + FirstNoticeOfLossID + "_" + lastDocumentId;
                        var    path     = @"~/DocumentsFirstNoticeOfLoss/HealthInsurance/" + fileName;
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));
                        var document = new document();
                        document.Name = fileName;
                        var documentID = _fis.AddDocument(document);
                        _fis.AddDocumentToFirstNoticeOfLoss(documentID, FirstNoticeOfLossID);
                    }
                }
            }

            if (documentsLuggage != null)
            {
                foreach (var file in documentsLuggage)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        var path = @"~/DocumentsFirstNoticeOfLoss/LuggageInsurance/" + file.FileName;
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));
                        var document = new document();
                        document.Name = file.FileName;
                        var documentID = _fis.AddDocument(document);
                        _fis.AddDocumentToFirstNoticeOfLoss(documentID, FirstNoticeOfLossID);
                    }
                }
            }
            result = FirstNoticeOfLossID;
            return(result);
        }
Exemplo n.º 5
0
        public static void UpdateAdditionalInfo(FirstNoticeOfLossEditViewModel model, IFirstNoticeOfLossService _fnol, IAdditionalInfoService _ais, ILuggageInsuranceService _lis, IHealthInsuranceService _his)
        {
            var fnol           = _fnol.GetById(model.Id);
            var additionalInfo = fnol.additional_info;

            if (fnol.additional_info.health_insurance_info != null)
            {
                var healthInfo = fnol.additional_info.health_insurance_info;
                additionalInfo.Accident_place    = model.AccidentPlaceHealth;
                additionalInfo.Datetime_accident = model.AccidentDateTimeHealth ?? new DateTime(0, 0, 0);
                additionalInfo.Datetime_accident.Add(model.AccidentTimeHealth ?? new TimeSpan(0, 0, 0));

                healthInfo.Datetime_doctor_visit    = model.DoctorVisitDateTime;
                healthInfo.Doctor_info              = model.DoctorInfo;
                healthInfo.Medical_case_description = model.MedicalCaseDescription;
                healthInfo.Previous_medical_history = model.PreviousMedicalHistory;
                healthInfo.Responsible_institution  = model.ResponsibleInstitution;

                _ais.UpdateAdditionalAndHealthInfo(additionalInfo, healthInfo);
            }
            else
            {
                var luggageInfo = fnol.additional_info.luggage_insurance_info;
                additionalInfo.Accident_place = model.AccidentPlaceLuggage;

                additionalInfo.Datetime_accident = model.AccidentDateTimeLuggage ?? new DateTime(0, 0, 0);
                //additionalInfo.Datetime_accident.Add(model.AccidentTimeLuggage ?? new TimeSpan(0, 0, 0));
                var a = additionalInfo.Datetime_accident.Date + model.AccidentTimeLuggage;
                additionalInfo.Datetime_accident = a ?? new DateTime(0, 0, 0);


                luggageInfo.Place_description     = model.PlaceDescription;
                luggageInfo.Detail_description    = model.DetailDescription;
                luggageInfo.Report_place          = model.ReportPlace;
                luggageInfo.Floaters              = model.Floaters;
                luggageInfo.Floaters_value        = Int64.Parse(model.FloatersValue);
                luggageInfo.Luggage_checking_Time = model.LugaggeCheckingTime ?? new TimeSpan(0, 0, 0);

                _ais.UpdateAdditionalAndLuggageInfo(additionalInfo, luggageInfo);
            }
        }
Exemplo n.º 6
0
        public static bool ArchiveFirstNoticeOfLoss(first_notice_of_loss firstNoticeOfLoss,
                                                    string modifiedBy,
                                                    IFirstNoticeOfLossService _fnol,
                                                    IFirstNoticeOfLossArchiveService _firstNoticeLossArchive)
        {
            first_notice_of_loss_archive firstNoticeOfLossArchive = new first_notice_of_loss_archive();

            firstNoticeOfLossArchive.fnol_ID                        = firstNoticeOfLoss.ID;
            firstNoticeOfLossArchive.ModifiedBy                     = modifiedBy;
            firstNoticeOfLossArchive.Modified_Datetime              = DateTime.Now;
            firstNoticeOfLossArchive.CreatedBy                      = firstNoticeOfLoss.CreatedBy;
            firstNoticeOfLossArchive.Created_Datetime               = firstNoticeOfLoss.CreatedDateTime;
            firstNoticeOfLossArchive.ChatID                         = firstNoticeOfLoss.ChatId;
            firstNoticeOfLossArchive.Short_Detailed                 = firstNoticeOfLoss.Short_Detailed;
            firstNoticeOfLossArchive.Web_Mobile                     = firstNoticeOfLoss.Web_Mobile;
            firstNoticeOfLossArchive.Total_cost                     = firstNoticeOfLoss.Total_cost;
            firstNoticeOfLossArchive.Transport_means                = firstNoticeOfLoss.Transport_means;
            firstNoticeOfLossArchive.Arrival_Date_Time              = firstNoticeOfLoss.Arrival_Date_Time;
            firstNoticeOfLossArchive.Depart_Date_Time               = firstNoticeOfLoss.Depart_Date_Time;
            firstNoticeOfLossArchive.Destination                    = firstNoticeOfLoss.Destination;
            firstNoticeOfLossArchive.PolicyId                       = firstNoticeOfLoss.PolicyId;
            firstNoticeOfLossArchive.Relation                       = firstNoticeOfLoss.Relation_claimant_policy_holder;
            firstNoticeOfLossArchive.Policy_Holder_Name             = firstNoticeOfLoss.travel_policy.insured.Name;
            firstNoticeOfLossArchive.Policy_Holder_Last_Name        = firstNoticeOfLoss.travel_policy.insured.Lastname;
            firstNoticeOfLossArchive.Policy_HolderId                = firstNoticeOfLoss.travel_policy.insured.ID;
            firstNoticeOfLossArchive.Policy_Holder_Address          = firstNoticeOfLoss.travel_policy.insured.Address + " " + firstNoticeOfLoss.travel_policy.insured.City + " " + firstNoticeOfLoss.travel_policy.insured.Postal_Code;
            firstNoticeOfLossArchive.Policy_Holder_Phone            = firstNoticeOfLoss.travel_policy.insured.Phone_Number;
            firstNoticeOfLossArchive.Policy_Holder_Ssn              = firstNoticeOfLoss.travel_policy.insured.SSN;
            firstNoticeOfLossArchive.Policy_Holder_BankAccountId    = firstNoticeOfLoss.Policy_holder_bank_accountID;
            firstNoticeOfLossArchive.ClaimantId                     = firstNoticeOfLoss.insured.ID;
            firstNoticeOfLossArchive.Claimant_BankAccountId         = firstNoticeOfLoss.Claimant_bank_accountID;
            firstNoticeOfLossArchive.Claimant_Address               = firstNoticeOfLoss.insured.Address + " " + firstNoticeOfLoss.insured.City + " " + firstNoticeOfLoss.insured.Postal_Code;
            firstNoticeOfLossArchive.Claimant_Last_Name             = firstNoticeOfLoss.insured.Lastname;
            firstNoticeOfLossArchive.Claimant_Name                  = firstNoticeOfLoss.insured.Name;
            firstNoticeOfLossArchive.Claimant_Phone                 = firstNoticeOfLoss.insured.Phone_Number;
            firstNoticeOfLossArchive.Claimant_Ssn                   = firstNoticeOfLoss.insured.SSN;
            firstNoticeOfLossArchive.Additional_infoId              = firstNoticeOfLoss.Additional_infoID;
            firstNoticeOfLossArchive.Additional_info_datetime       = firstNoticeOfLoss.additional_info.Datetime_accident;
            firstNoticeOfLossArchive.Additional_info_accident_place = firstNoticeOfLoss.additional_info.Accident_place;
            firstNoticeOfLossArchive.FNOL_Number                    = firstNoticeOfLoss.FNOL_Number;

            if (firstNoticeOfLoss.additional_info.luggage_insurance_info != null)
            {
                firstNoticeOfLossArchive.luggage_place_description  = firstNoticeOfLoss.additional_info.luggage_insurance_info.Place_description;
                firstNoticeOfLossArchive.luggage_detail_description = firstNoticeOfLoss.additional_info.luggage_insurance_info.Detail_description;
                firstNoticeOfLossArchive.luggage_report_place       = firstNoticeOfLoss.additional_info.luggage_insurance_info.Report_place;
                firstNoticeOfLossArchive.luggage_floaters           = firstNoticeOfLoss.additional_info.luggage_insurance_info.Floaters;
                firstNoticeOfLossArchive.luggage_floaters_value     = firstNoticeOfLoss.additional_info.luggage_insurance_info.Floaters_value;
                firstNoticeOfLossArchive.luggage_checking_time      = firstNoticeOfLoss.additional_info.luggage_insurance_info.Luggage_checking_Time;
            }
            else if (firstNoticeOfLoss.additional_info.health_insurance_info != null)
            {
                firstNoticeOfLossArchive.health_datetime_doctor_visit    = firstNoticeOfLoss.additional_info.health_insurance_info.Datetime_doctor_visit;
                firstNoticeOfLossArchive.health_doctor_info              = firstNoticeOfLoss.additional_info.health_insurance_info.Doctor_info;
                firstNoticeOfLossArchive.health_medical_case_description = firstNoticeOfLoss.additional_info.health_insurance_info.Medical_case_description;
                firstNoticeOfLossArchive.health_responsible_institution  = firstNoticeOfLoss.additional_info.health_insurance_info.Responsible_institution;
                firstNoticeOfLossArchive.health_previous_medical_history = firstNoticeOfLoss.additional_info.health_insurance_info.Previous_medical_history;
            }

            var result = _firstNoticeLossArchive.Archive(firstNoticeOfLossArchive);

            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public static void UpdateFirstNoticeOfLoss(FirstNoticeOfLossEditViewModel model,
                                                   IFirstNoticeOfLossService _fnol,
                                                   IBankAccountService _bas,
                                                   IAdditionalInfoService _ais,
                                                   IHealthInsuranceService _his,
                                                   ILuggageInsuranceService _lis,
                                                   IFirstNoticeOfLossArchiveService _firstNoticeLossArchive,
                                                   IEnumerable <HttpPostedFileBase> invoices,
                                                   IEnumerable <HttpPostedFileBase> documentsHealth,
                                                   IEnumerable <HttpPostedFileBase> documentsLuggage)
        {
            var fnol = _fnol.GetById(model.Id);
            //bank accounts update
            var isArchived = ArchiveFirstNoticeOfLossHelper.ArchiveFirstNoticeOfLoss(fnol, model.ModifiedBy, _fnol, _firstNoticeLossArchive);

            if (!fnol.Claimant_bank_account_info.Account_Number.ToString().Equals(model.ClaimantBankAccountNumber) ||
                !fnol.Claimant_bank_account_info.bank.Name.Equals(model.ClaimantBankName))
            {
                var bankAccountId = UpdateBankAccountInfoHelper.UpdateBankAccountInfo(fnol.Claimant_bank_accountID, model.ClaimantBankAccountNumber.Trim(), model.ClaimantBankName, fnol.ClaimantId, _bas);
                _fnol.UpdateClaimantBankAccountId(fnol.ID, bankAccountId);
            }

            if (!fnol.Policy_holder_bank_account_info.Account_Number.ToString().Equals(model.PolicyHolderBankAccountNumber) ||
                !fnol.Policy_holder_bank_account_info.bank.Name.Equals(model.PolicyHolderBankName))
            {
                var bankAccountId = UpdateBankAccountInfoHelper.UpdateBankAccountInfo(fnol.Policy_holder_bank_accountID, model.PolicyHolderBankAccountNumber.Trim(), model.PolicyHolderBankName, fnol.travel_policy.Policy_HolderID, _bas);
                _fnol.UpdatePolicyHolderBankAccountId(fnol.ID, bankAccountId);
            }

            UpdateAdditionalInfoHelper.UpdateAdditionalInfo(model, _fnol, _ais, _lis, _his);

            //jos vkupna vrednost i dokumenti
            var newFnol = fnol;

            newFnol.Modified_Datetime = DateTime.Now;
            newFnol.ModifiedBy        = model.ModifiedBy;
            newFnol.Destination       = model.Destination;
            newFnol.Depart_Date_Time  = model.DepartDateTime.Date;
            newFnol.Depart_Date_Time  = model.DepartDateTime.Date + (model.DepartTime ?? new TimeSpan(0, 0, 0));
            //newFnol.Depart_Date_Time = new DateTime(model.DepartDateTime.Year,);

            newFnol.Arrival_Date_Time = model.ArrivalDateTime.Date;
            newFnol.Arrival_Date_Time = model.ArrivalDateTime.Date + (model.ArriveTime ?? new TimeSpan(0, 0, 0));
            newFnol.Transport_means   = model.TransportMeans;
            newFnol.Relation_claimant_policy_holder = model.RelationClaimantPolicyHolder;
            newFnol.Total_cost = model.TotalCost;
            _fnol.Update(newFnol);

            if (invoices != null)
            {
                foreach (var file in invoices)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        var path = @"~/DocumentsFirstNoticeOfLoss/Invoices/" + file.FileName;
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));

                        var document = new document();
                        document.Name = file.FileName;
                        var documentID = _fnol.AddDocument(document);
                        _fnol.AddInvoice(documentID);
                        _fnol.AddDocumentToFirstNoticeOfLoss(documentID, fnol.ID);
                    }
                }
            }

            if (documentsHealth != null)
            {
                foreach (var file in documentsHealth)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        var path = @"~/DocumentsFirstNoticeOfLoss/HealthInsurance/" + file.FileName;
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));
                        var document = new document();
                        document.Name = file.FileName;
                        var documentID = _fnol.AddDocument(document);
                        _fnol.AddDocumentToFirstNoticeOfLoss(documentID, fnol.ID);
                    }
                }
            }

            if (documentsLuggage != null)
            {
                foreach (var file in documentsLuggage)
                {
                    if (file != null && file.ContentLength > 0)
                    {
                        var path = @"~/DocumentsFirstNoticeOfLoss/LuggageInsurance/" + file.FileName;
                        file.SaveAs(System.Web.HttpContext.Current.Server.MapPath(path));
                        var document = new document();
                        document.Name = file.FileName;
                        var documentID = _fnol.AddDocument(document);
                        _fnol.AddDocumentToFirstNoticeOfLoss(documentID, fnol.ID);
                    }
                }
            }
        }