public async void CreateClaim(ClaimViewModel claim)
        {
            var uri          = API.Claim.PostClaim(_remoteServiceBaseUrl);
            var claimContent = new StringContent(JsonConvert.SerializeObject(claim), System.Text.Encoding.UTF8, "application/json");

            //var response = await _httpClient.PutAsync(uri, claimContent);

            //if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
            //{
            //    throw new Exception("Error in clim creation process, try later.");
            //}

            //response.EnsureSuccessStatusCode();

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("http://localhost:5000/");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            HttpResponseMessage response = await client.PostAsync("api/claims", claimContent);

            response.EnsureSuccessStatusCode();
        }
Esempio n. 2
0
        public async Task <ActionResult> Unsubscribe(int projectid, int claimid)
        {
            var user = await GetCurrentUserAsync();

            var claim = await _claimsRepository.GetClaim(projectid, claimid);

            if (claim == null)
            {
                return(HttpNotFound());
            }

            var claimViewModel = new ClaimViewModel(user, claim,
                                                    Enumerable.Empty <PluginOperationData <IPrintCardPluginOperation> >(), new PlotElement[] { },
                                                    UriService);


            await _claimService.UnsubscribeClaimToUser(projectid, claimid);

            var parents = claim.GetTarget().GetParentGroupsToTop();

            var tooltip = claimViewModel.GetFullSubscriptionTooltip(parents, user.Subscriptions, claimViewModel.ClaimId);

            return(Json(tooltip, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
 public void RemoveClaim(ClaimViewModel claim)
 {
     this.Claims.Remove(claim);
     this.RaisePropertyChanged(nameof(SettingsViewModel.Claims));
 }
Esempio n. 4
0
 private bool Equals(ClaimViewModel other)
 {
     return string.Equals(Operation, other.Operation) && string.Equals(Resource, other.Resource);
 }
Esempio n. 5
0
        private async Task <ActionResult> ShowClaim(Claim claim)
        {
            var error = WithClaim(claim);

            if (error != null)
            {
                return(error);
            }

            var printPlugins = claim.HasMasterAccess(CurrentUserId) && claim.IsApproved
        ? (PluginFactory.GetProjectOperations <IPrintCardPluginOperation>(claim.Project)).Where(
                p => p.AllowPlayerAccess || claim.HasMasterAccess(CurrentUserId))
        : Enumerable.Empty <PluginOperationData <IPrintCardPluginOperation> >();

            var currentUser = await GetCurrentUserAsync().ConfigureAwait(false);

            var plots = claim.IsApproved && claim.Character != null
        ? await _plotRepository.GetPlotsForCharacter(claim.Character).ConfigureAwait(false)
        : new PlotElement[]
            {
            };

            IEnumerable <ProjectAccommodationType>        availableAccommodation  = null;
            IEnumerable <AccommodationRequest>            requestForAccommodation = null;
            IEnumerable <AccommodationPotentialNeighbors> potentialNeighbors      = null;
            IEnumerable <AccommodationInvite>             incomingInvite          = null;
            IEnumerable <AccommodationInvite>             outgoingInvite          = null;


            if (claim.Project.Details.EnableAccommodation)
            {
                availableAccommodation = await
                                         _accommodationRepository.GetAccommodationForProject(claim.ProjectId).ConfigureAwait(false);

                requestForAccommodation = await _accommodationRequestRepository
                                          .GetAccommodationRequestForClaim(claim.ClaimId).ConfigureAwait(false);

                var acceptedRequest = requestForAccommodation
                                      .FirstOrDefault(request => request.IsAccepted == AccommodationRequest.InviteState.Accepted);
                var acceptedRequestId = acceptedRequest?.Id;
                var acceptedRequestAccommodationTypeIdId = acceptedRequest?.AccommodationTypeId;

                if (acceptedRequestId != null)
                {
                    var sameRequest = (await
                                       _accommodationRequestRepository.GetClaimsWithSameAccommodationTypeToInvite(
                                           acceptedRequestAccommodationTypeIdId.Value).ConfigureAwait(false)).Where(c => c.ClaimId != claim.ClaimId)
                                      .Select(c => new AccommodationPotentialNeighbors(c, NeighborType.WithSameType));;
                    var noRequest = (await
                                     _accommodationRequestRepository.GetClaimsWithOutAccommodationRequest(claim.ProjectId).ConfigureAwait(false)).Select(c => new AccommodationPotentialNeighbors(c, NeighborType.NoRequest));;
                    var currentNeighbors = (await
                                            _accommodationRequestRepository.GetClaimsWithSameAccommodationRequest(
                                                acceptedRequestId.Value).ConfigureAwait(false)).Select(c => new AccommodationPotentialNeighbors(c, NeighborType.Current));
                    potentialNeighbors = sameRequest.Union(noRequest).Where(element => currentNeighbors.All(el => el.ClaimId != element.ClaimId));
                }

                incomingInvite = await AccommodationInviteRepository.GetIncomingInviteForClaim(claim).ConfigureAwait(false);

                outgoingInvite = await AccommodationInviteRepository.GetOutgoingInviteForClaim(claim).ConfigureAwait(false);
            }

            var claimViewModel = new ClaimViewModel(currentUser, claim, printPlugins, plots, UriService, availableAccommodation, requestForAccommodation, potentialNeighbors, incomingInvite, outgoingInvite);

            if (claim.CommentDiscussion.Comments.Any(c => !c.IsReadByUser(CurrentUserId)))
            {
                await
                _claimService.UpdateReadCommentWatermark(claim.ProjectId, claim.CommentDiscussion.CommentDiscussionId,
                                                         claim.CommentDiscussion.Comments.Max(c => c.CommentId)).ConfigureAwait(false);
            }


            var parents = claim.GetTarget().GetParentGroupsToTop();

            claimViewModel.SubscriptionTooltip =
                claimViewModel.GetFullSubscriptionTooltip(parents, currentUser.Subscriptions, claimViewModel.ClaimId);

            return(View("Edit", claimViewModel));
        }
Esempio n. 6
0
        public ActionResult Save(ClaimViewModel model)
        {
            RePairClaim(model.Claim);
            //var validateWithProject = model.Claim.ValidateDateClaimInfoWithProject();
            //var validateWithClient = model.Claim.CheckClaimClient();
            //var validateWithServer = model.Claim.CheckClaimServer();
            //if (validateWithProject.Count > 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Claim information must in range startdate - enddate");
            //    model.ListClaimInfoError = model.ListClaimInfoError.Union(validateWithProject).ToList();
            //}

            //if (validateWithClient.Count > 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Claim information time range is not valid");
            //    model.ListClaimInfoError = model.ListClaimInfoError.Union(validateWithClient).ToList();
            //}

            //if (validateWithServer.Count > 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Duplicated Claim !There is already claim in this time range.");
            //    model.ListClaimInfoError = model.ListClaimInfoError.Union(validateWithServer).ToList();
            //}

            //if (model.Claim.claimInfos.Count == 0)
            //{
            //    ModelState.AddModelError(string.Empty, "Please add some claim information");
            //}

            if (ModelState.IsValid)
            {
                Claim claim = new Claim()
                {
                    ClaimId          = model.Claim.ClaimId,
                    AuditTrail       = model.Claim.AuditTrail,
                    ProjectId        = model.Claim.ProjectId,
                    Remark           = model.Claim.Remark,
                    Status           = model.Claim.Status,
                    StaffId          = model.Claim.StaffId,
                    TotalWorkingHour = model.Claim.TotalWorkingHour,
                    ClaimInfors      = model.Claim.ClaimInfors
                };
                claim.AuditTrail = claim.AuditTrail ?? "";
                if (model.ClaimAction.Equals("Submit"))
                {
                    claim.Status = (int)ClaimStatus.PendingApproval;
                    if (claim.ClaimId == Guid.Empty)
                    {
                        //submit at first time
                        claim.AuditTrail += "\nSubmitted on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Add(claim);
                    }
                    else
                    {
                        //submit at update
                        claim.AuditTrail += "\nUpdated on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        claim.AuditTrail += "\nSubmitted on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Update(claim);
                    }
                    //EmailSender.SendReminderAsync(claim);
                }
                else
                {
                    if (claim.ClaimId == Guid.Empty)
                    {
                        //save at first time
                        claim.AuditTrail += "Created on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Add(claim);
                    }
                    else
                    {
                        //save at update
                        claim.AuditTrail += "\nUpdated on << " + DateTime.Now + " >> by << " + User.Identity.GetUserName() + " >>";
                        _claimRepository.Update(claim);
                    }
                }
                return(Json(new { IsSuccess = true, ClaimId = claim.ClaimId }));
            }
            GetRelatData(model);
            model.Claim.Status = (int)ClaimStatus.Draft;
            //return PartialView("_PartialFormSaveClaim", model);
            return(View("Create"));
        }
Esempio n. 7
0
        public async Task <bool> EditUserProfileAsync(EditProfileViewModel profile)
        {
            var user = await GetUserByEmailAsync(_httpContextAccessor.HttpContext.User.Identity.Name);

            if (user == null)
            {
                return(false);
            }

            if (profile.ImageFile != null)
            {
                if (profile.ImageFile.Length > 1000000)
                {
                    return(false);
                }

                if (profile.ImageName != "default-avatar.png")
                {
                    var oldImagePath = Path.Combine(Directory.GetCurrentDirectory(),
                                                    "wwwroot/images/avatars/", user.Avatar);

                    if (File.Exists(oldImagePath))
                    {
                        File.Delete(oldImagePath);
                    }
                    else
                    {
                        //TODO: Log error
                        Console.WriteLine($"The image path cannot be found. Path = {oldImagePath}");
                    }
                }

                user.Avatar = Generator.GenerationUniqueName() + Path.GetExtension(profile.ImageFile.FileName);

                var newImagePath = Path.Combine(
                    Directory.GetCurrentDirectory(), "wwwroot/images/avatars/", user.Avatar
                    );
                await using (var stream = new FileStream(newImagePath, FileMode.Create))
                {
                    await profile.ImageFile.CopyToAsync(stream);
                }
            }

            await DeleteCookieAsync();

            var claims = new ClaimViewModel()
            {
                Email      = OptimizeText.OptimizeEmail(profile.Email),
                Name       = profile.Name,
                RememberMe = Convert.ToBoolean(_httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.AuthenticationMethod).Value)
            };

            await CreateCookieAsync(claims);

            user.Name  = profile.Name;
            user.Email = OptimizeText.OptimizeEmail(profile.Email);

            await UpdateUserAsync(user);

            return(true);
        }
Esempio n. 8
0
        public async Task <ClaimViewModel> Update(ClaimViewModel viewModel)
        {
            var claimInfo = this.ClaimRepository.Find(viewModel.ClaimId);

            if (claimInfo != null && claimInfo.IsActive)
            {
                var lastModifiedDate = claimInfo.LastModifiedOn;

                claimInfo.CompanyId            = viewModel.Company.CompanyId;
                claimInfo.ContactId            = viewModel.Contact.ContactId;
                claimInfo.ClaimNo              = viewModel.ClaimNo;
                claimInfo.ClaimantId           = viewModel.Claimant.ContactId;
                claimInfo.PolicyNo             = viewModel.PolicyNo;
                claimInfo.PolicyEffectiveDate  = !string.IsNullOrWhiteSpace(viewModel.PolicyEffectiveDate) ? DateTime.ParseExact(viewModel.PolicyEffectiveDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                claimInfo.PolicyExpirationDate = !string.IsNullOrWhiteSpace(viewModel.PolicyExpirationDate) ? DateTime.ParseExact(viewModel.PolicyExpirationDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                claimInfo.LoanNo                   = viewModel.LoanNo;
                claimInfo.Mortgagee                = viewModel.Mortgagee;
                claimInfo.ReceivedDate             = !string.IsNullOrWhiteSpace(viewModel.ReceivedDate) ? DateTime.ParseExact(viewModel.ReceivedDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now;
                claimInfo.LossDate                 = !string.IsNullOrWhiteSpace(viewModel.LossDate) ? DateTime.ParseExact(viewModel.LossDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now;
                claimInfo.LossType                 = viewModel.LossType;
                claimInfo.AdjustmentType           = viewModel.AdjustmentType;
                claimInfo.LossTotalUrgent          = viewModel.LossTotalUrgent;
                claimInfo.MouldClaim               = viewModel.MouldClaim;
                claimInfo.ManagerId                = viewModel.Manager.UserId;
                claimInfo.AdjusterId               = viewModel.Adjuster.UserId;
                claimInfo.Branch                   = viewModel.Branch;
                claimInfo.LossDescription          = viewModel.LossDescription;
                claimInfo.Instruction              = viewModel.Instruction;
                claimInfo.VinNo                    = viewModel.VinNo;
                claimInfo.Deductible               = viewModel.Deductible;
                claimInfo.WindDeductible           = viewModel.WindDeductible;
                claimInfo.Premium                  = viewModel.Premium;
                claimInfo.Building                 = viewModel.Building;
                claimInfo.Subrogation              = viewModel.Subrogation;
                claimInfo.Salvage                  = viewModel.Salvage;
                claimInfo.BusinessPersonalProperty = viewModel.BusinessPersonalProperty;
                claimInfo.Contents                 = viewModel.Contents;
                claimInfo.Ale = viewModel.Ale;
                claimInfo.DetachedPrivateStructures = viewModel.DetachedPrivateStructures;
                claimInfo.CondominiumImprovements   = viewModel.CondominiumImprovements;
                claimInfo.IndustrialHygenist        = viewModel.IndustrialHygenist;
                claimInfo.AdjustingFee        = !string.IsNullOrWhiteSpace(viewModel.AdjustingFee) ? Convert.ToDecimal(viewModel.AdjustingFee) : (decimal?)null;
                claimInfo.FirstContactDate    = !string.IsNullOrWhiteSpace(viewModel.FirstContactDate) ? DateTime.ParseExact(viewModel.FirstContactDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now;
                claimInfo.InspectionDate      = !string.IsNullOrWhiteSpace(viewModel.InspectionDate) ? DateTime.ParseExact(viewModel.InspectionDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                claimInfo.DueDate             = !string.IsNullOrWhiteSpace(viewModel.DueDate) ? DateTime.ParseExact(viewModel.DueDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null;
                claimInfo.AcknowledgementMail = viewModel.AcknowledgementMail;
                claimInfo.LossNotice          = viewModel.LossNotice;
                claimInfo.ClaimStatusId       = viewModel.StatusId;
                claimInfo.LastModifiedBy      = viewModel.LastModifiedBy;
                claimInfo.LastModifiedOn      = viewModel.LastModifiedOn;
                claimInfo.IsActive            = viewModel.IsActive;

                claimInfo = this.ClaimRepository.Update(claimInfo);

                if (lastModifiedDate < claimInfo.LastModifiedOn)
                {
                    return(viewModel);
                }
                else
                {
                    viewModel.HasError = true;
                }
            }

            return(viewModel);
        }
Esempio n. 9
0
 public ResponseModel <bool> Claim_Update([FromBody] ClaimViewModel model)
 {
     return(_aspNetRolesServices.Claim_Update(model));
 }
Esempio n. 10
0
        public IActionResult Update(int id, ClaimViewModel claim)
        {
            // Map to ViewModel - Replace with Automapper
            Claim _claim = new Claim();

            _claim.LineItems    = new System.Collections.Generic.List <Shared.Models.LineItem>();
            _claim.Id           = claim.Id;
            _claim.Patient      = claim.SelectedPatient.Name;
            _claim.Organization = claim.SelectedOrganization.Name;
            _claim.Type         = claim.Type;
            _claim.Status       = claim.Status;
            foreach (BlazorCrud.Shared.ViewModels.LineItem li in claim.LineItems)
            {
                BlazorCrud.Shared.Models.LineItem _li = new Shared.Models.LineItem();
                _li.Id      = li.Id;
                _li.Service = li.Service;
                _li.Amount  = li.Amount;
                _claim.LineItems.Add(_li);
            }

            if (ModelState.IsValid)
            {
                var existingClaim = _context.Claims
                                    .Include(c => c.LineItems)
                                    .Single(c => c.Id == id);
                if (existingClaim == null)
                {
                    return(NotFound());
                }

                // Update Existing Claim
                existingClaim.ModifiedDate = DateTime.Now;
                _context.Entry(existingClaim).CurrentValues.SetValues(claim);

                // Delete Line Items
                foreach (var existingLineItem in existingClaim.LineItems.ToList())
                {
                    if (!claim.LineItems.Any(c => c.Id == existingLineItem.Id))
                    {
                        _context.LineItems.Remove(existingLineItem);
                    }
                }

                // Update and Insert Line Items
                foreach (var lineItemModel in claim.LineItems)
                {
                    var existingLineItem = existingClaim.LineItems
                                           .Where(c => c.Id == lineItemModel.Id)
                                           .SingleOrDefault();
                    if (existingLineItem != null)
                    {
                        _context.Entry(existingLineItem).CurrentValues.SetValues(lineItemModel);
                    }
                    else
                    {
                        var newLineItem = new Shared.Models.LineItem
                        {
                            Id      = lineItemModel.Id,
                            Service = lineItemModel.Service,
                            Amount  = lineItemModel.Amount
                        };
                        existingClaim.LineItems.Add(newLineItem);
                    }
                }

                _context.SaveChanges();

                return(NoContent());
            }
            else
            {
                return(BadRequest(ModelState));
            }
        }
Esempio n. 11
0
 public static void Map(Claim source, ClaimViewModel target)
 {
     target.Value = source.Value;
 }
Esempio n. 12
0
 public async Task <UserClaimResponse> RemoveClaim([FromRoute] string userId, [FromBody] ClaimViewModel claim)
 {
     return(await _mediator.Send(new RemoveClaimCommand(userId, claim)));
 }
 public async void IncluirClaimUsuario(string codUsuario, ClaimViewModel claim)
 {
     await _userManager.AddClaimAsync(codUsuario, new Claim(claim.Type, claim.Value));
 }
Esempio n. 14
0
 public ActionResult New(ClaimViewModel claim)
 {
     return(View(claim));
 }
Esempio n. 15
0
        public IActionResult Post([FromBody] ClaimViewModel claim)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Create the bear minimal claim
            var newClaim = _mapper.Map <ClaimViewModel, Claim>(claim);

            newClaim.ClaimInitiationDate = DateTime.Now;

            _unitOfWork.Claims.Add(newClaim);
            // Commit changes to the database to get ClaimId
            _unitOfWork.SaveChanges();

            // Iterate through ClaimViewModel to get ClaimDiagnosis, ClaimDrugs, ClaimDoctors, ClaimServices
            // ClaimDiagnosis
            foreach (var claimDiagnosis in claim.ClaimDiagnosis)
            {
                var newClaimDiagnosis = _mapper.Map <ClaimDiagnosisViewModel, ClaimDiagnosis>(claimDiagnosis);
                // Assign the newly created Claim Id to the Diagnosis
                newClaimDiagnosis.ClaimId = newClaim.Id;
                _unitOfWork.ClaimDiagnoses.Add(newClaimDiagnosis);
            }
            // Commit changes to the database
            _unitOfWork.SaveChanges();

            // ClaimDoctors
            foreach (var claimDoctor in claim.ClaimDoctors)
            {
                var newClaimDoctor = _mapper.Map <ClaimDoctorViewModel, ClaimDoctors>(claimDoctor);
                // Assign the newly created Claim Id to the Diagnosis
                newClaimDoctor.ClaimId = newClaim.Id;
                _unitOfWork.ClaimDoctors.Add(newClaimDoctor);
            }
            // Commit changes to the database
            _unitOfWork.SaveChanges();

            // ClaimDrugs
            foreach (var claimDrug in claim.ClaimDrugs)
            {
                var newClaimDrug = _mapper.Map <ClaimDrugViewModel, ClaimDrugs>(claimDrug);
                // Assign the newly created Claim Id to the Diagnosis
                newClaimDrug.ClaimId = newClaim.Id;
                _unitOfWork.ClaimDrugs.Add(newClaimDrug);
            }
            // Commit changes to the database
            _unitOfWork.SaveChanges();

            // ClaimServices
            foreach (var claimService in claim.ClaimServices)
            {
                var newClaimService = _mapper.Map <ClaimServiceViewModel, ClaimServices>(claimService);
                // Assign the newly created Claim Id to the Diagnosis
                newClaimService.ClaimId = newClaim.Id;
                _unitOfWork.ClaimServicesProvided.Add(newClaimService);
            }
            // Commit changes to the database
            _unitOfWork.SaveChanges();

            CreatedAtRouteResult result = CreatedAtRoute("Get", new { controller = "Claims", id = newClaim.Id }, newClaim);

            return(result);
        }
Esempio n. 16
0
        public async Task <ClaimViewModel> Create(ClaimViewModel viewModel)
        {
            var claim = new Claim
            {
                FileNo = string.Format("{0}-{1}-{2:000000}"
                                       , viewModel.Company != null && !string.IsNullOrWhiteSpace(viewModel.Company.CompanyName) && viewModel.Company.CompanyName.Length > 3
                                                        ? viewModel.Company.CompanyName.Substring(0, 3) : "COM"
                                       , DateTime.Now.Year
                                       , (new Random()).Next(1, 999999)),
                ClaimNo              = viewModel.ClaimNo,
                CompanyId            = viewModel.Company.CompanyId,
                ContactId            = viewModel.Contact.ContactId,
                ClaimantId           = viewModel.Claimant.ContactId,
                PolicyNo             = viewModel.PolicyNo,
                PolicyEffectiveDate  = !string.IsNullOrWhiteSpace(viewModel.PolicyEffectiveDate) ? DateTime.ParseExact(viewModel.PolicyEffectiveDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null,
                PolicyExpirationDate = !string.IsNullOrWhiteSpace(viewModel.PolicyExpirationDate) ? DateTime.ParseExact(viewModel.PolicyExpirationDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null,
                LoanNo                   = viewModel.LoanNo,
                Mortgagee                = viewModel.Mortgagee,
                ReceivedDate             = !string.IsNullOrWhiteSpace(viewModel.ReceivedDate) ? DateTime.ParseExact(viewModel.ReceivedDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now,
                LossDate                 = !string.IsNullOrWhiteSpace(viewModel.LossDate) ? DateTime.ParseExact(viewModel.LossDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now,
                LossType                 = viewModel.LossType,
                AdjustmentType           = viewModel.AdjustmentType,
                LossTotalUrgent          = viewModel.LossTotalUrgent,
                MouldClaim               = viewModel.MouldClaim,
                ManagerId                = viewModel.Manager.UserId,
                AdjusterId               = viewModel.Adjuster.UserId,
                Branch                   = viewModel.Branch,
                LossDescription          = viewModel.LossDescription,
                Instruction              = viewModel.Instruction,
                VinNo                    = viewModel.VinNo,
                Deductible               = viewModel.Deductible,
                WindDeductible           = viewModel.WindDeductible,
                Premium                  = viewModel.Premium,
                Building                 = viewModel.Building,
                Subrogation              = viewModel.Subrogation,
                Salvage                  = viewModel.Salvage,
                BusinessPersonalProperty = viewModel.BusinessPersonalProperty,
                Contents                 = viewModel.Contents,
                Ale = viewModel.Ale,
                DetachedPrivateStructures = viewModel.DetachedPrivateStructures,
                CondominiumImprovements   = viewModel.CondominiumImprovements,
                IndustrialHygenist        = viewModel.IndustrialHygenist,
                AdjustingFee        = !string.IsNullOrWhiteSpace(viewModel.AdjustingFee) ? Convert.ToDecimal(viewModel.AdjustingFee) : (decimal?)null,
                FirstContactDate    = !string.IsNullOrWhiteSpace(viewModel.FirstContactDate) ? DateTime.ParseExact(viewModel.FirstContactDate, "M/d/yyyy", CultureInfo.InvariantCulture) : DateTime.Now,
                InspectionDate      = !string.IsNullOrWhiteSpace(viewModel.InspectionDate) ? DateTime.ParseExact(viewModel.InspectionDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null,
                DueDate             = !string.IsNullOrWhiteSpace(viewModel.DueDate) ? DateTime.ParseExact(viewModel.DueDate, "M/d/yyyy", CultureInfo.InvariantCulture) : (DateTime?)null,
                AcknowledgementMail = viewModel.AcknowledgementMail,
                LossNotice          = viewModel.LossNotice,
                ClaimStatusId       = viewModel.StatusId,
                CreatedBy           = viewModel.CreatedBy,
                CreatedOn           = viewModel.CreatedOn,
                LastModifiedBy      = viewModel.LastModifiedBy,
                LastModifiedOn      = viewModel.LastModifiedOn,
                IsActive            = viewModel.IsActive
            };

            claim = this.ClaimRepository.Add(claim);

            if (claim.ClaimId > 0)
            {
                viewModel.ClaimId = claim.ClaimId;
                viewModel.FileNo  = claim.FileNo;
            }
            else
            {
                viewModel.HasError = true;
            }

            return(viewModel);
        }
Esempio n. 17
0
        public ViewResult Claim()
        {
            var viewModel = new ClaimViewModel();

            return(View(viewModel));
        }
Esempio n. 18
0
        public async Task <IActionResult> Create(ClaimViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                //  Check if Claim Series has been set
                int claimPrefix = GetClaimPrefix(viewModel.PolicyID, viewModel.Claim.RiskID);
                if (claimPrefix > 0)
                {
                    //Random rnd = new Random();
                    Models.Claim claim  = viewModel.Claim;
                    var          riskId = viewModel.Claim.RiskID;
                    claim.ClaimNumber              = GetClaimNumber(claimPrefix);
                    claim.PolicyID                 = viewModel.PolicyID;
                    claim.ReserveInsuredRevised    = claim.ReserveInsured;
                    claim.ReserveThirdPartyRevised = claim.ReserveThirdParty;
                    _context.Add(claim);
                    await _context.SaveChangesAsync();

                    var claimNumber = claim.ClaimNumber;
                    var myParams    = new object[] { claimPrefix, claimNumber };

                    await _context.Database.ExecuteSqlCommandAsync(
                        "INSERT INTO ClaimNumberGenerator(ClaimPrefix, ClaimNumber) " +
                        "Values ({0}, {1})",
                        parameters : myParams);

                    Guid currentUserId = Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier));

                    var riskclaimdocuments = _context.RiskClaimDocuments.Where(r => r.RiskID == riskId);

                    if (riskclaimdocuments.Count() > 0)
                    {
                        foreach (var r in riskclaimdocuments)
                        {
                            var claimParams = new object[] { Guid.NewGuid(), claim.ClaimNumber, r.ClaimDocumentID, null, DateTime.Now,
                                     currentUserId, null, null };

                            await _context.Database.ExecuteSqlCommandAsync(
                                "INSERT INTO ClaimDocumentSubmit(ID, ClaimNumber, ClaimDocumentID, SubmitDate, " +
                                "DateAdded, AddedBy, DateModified, ModifiedBy) " +
                                "Values ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7})",
                                parameters : claimParams);
                        }
                    }
                    return(RedirectToAction("Index", new {
                        productId = viewModel.ProductID, clientId = viewModel.ClientID, policyid = viewModel.PolicyID
                    }));
                }
                else
                {
                    ViewData["ErrorMessage"]  = "Claim Number series not set";
                    viewModel.ClaimClassList  = new SelectList(await _context.ClaimClasses.AsNoTracking().ToListAsync(), "ID", "Name", viewModel.Claim.ClaimClassID);
                    viewModel.ClaimStatusList = new SelectList(await _context.ClaimStatuses.AsNoTracking().ToListAsync(), "ID", "Name", viewModel.Claim.ClaimStatusID);
                    viewModel.IncidentList    = new SelectList(await _context.Incidents
                                                               .Where(i => i.RiskIncidents.Any(r => r.RiskID == viewModel.Claim.RiskID))
                                                               .AsNoTracking().ToListAsync(),
                                                               "ID", "Name", viewModel.Claim.IncidentID);
                    viewModel.RegionList = new SelectList(await _context.Regions.AsNoTracking().ToListAsync(), "ID", "Name", viewModel.Claim.RegionID);
                    return(View(viewModel));
                }
            }
            viewModel.ClaimClassList  = new SelectList(await _context.ClaimClasses.AsNoTracking().ToListAsync(), "ID", "Name", viewModel.Claim.ClaimClassID);
            viewModel.ClaimStatusList = new SelectList(await _context.ClaimStatuses.AsNoTracking().ToListAsync(), "ID", "Name", viewModel.Claim.ClaimStatusID);
            viewModel.IncidentList    = new SelectList(await _context.Incidents
                                                       .Where(i => i.RiskIncidents.Any(r => r.RiskID == viewModel.Claim.RiskID))
                                                       .AsNoTracking().ToListAsync(),
                                                       "ID", "Name", viewModel.Claim.IncidentID);
            viewModel.RegionList = new SelectList(await _context.Regions.AsNoTracking().ToListAsync(), "ID", "Name", viewModel.Claim.RegionID);
            return(View(viewModel));
        }
 public ChangeClaimCommand(string userId, ClaimViewModel claim)
 {
     UserId = userId;
     Claim  = claim;
 }
Esempio n. 20
0
 public RoomInhabitantViewModel(RoomViewModel room, ClaimViewModel claim)
 {
     Claim     = claim;
     ProjectId = room.ProjectId;
     RoomId    = room.Id;
 }
Esempio n. 21
0
        public async Task <ActionResult> CreateClaim(ClaimViewModel claimViewModel, HttpPostedFileBase inputFile, bool printJobOrderAfterSave = false)
        {
            using (var context = new ApplicationDbContext())
            {
                var userIdentityid = User.Identity.GetUserId <int>();
                var employee       = await GetCurrentEmployee(context);

                if (ModelState.IsValid)
                {
                    var personalAccount =
                        context.PersonalAccount.FirstOrDefault(x => x.Id == claimViewModel.PersonalAccountId);
                    if (personalAccount == null)
                    {
                        throw new Exception($"Не найден ЛС с идентификатором: {claimViewModel.PersonalAccountId}");
                    }


                    var claim = new AbonentClaim
                    {
                        OrganizationId       = personalAccount.OrganizationId,
                        ApartmentFullAddress = personalAccount.ApartmentFullAddress,
                        ChangedTime          = DateTime.Now,
                        CreationTime         = DateTime.Now,
                        ContactPhoneNumber   = claimViewModel.ContactPhoneNumber,
                        PersonalAccountId    = personalAccount.Id,
                        DictClaimKindId      = claimViewModel.DictClaimKindId,
                        Description          = claimViewModel.Description,
                        ClaimStatus          = EClaimStatus.Created,
                        EmployeeId           = claimViewModel.EmployeeId,
                        EmployeeCreatorId    = employee.Id,
                        Cost = claimViewModel.Cost
                    };

                    if (inputFile != null && inputFile.ContentLength > 0)
                    {
                        var fileStorageManager =
                            OhConfigurator.Container.Resolve <IFileStorageManager>();
                        claim.ImportedFileId =
                            (await
                             fileStorageManager.SaveImportedFile(inputFile, userIdentityid, EImportType.AbonentFiles))
                            .Id;
                    }

                    context.AbonentClaim.Add(claim);
                    await context.SaveChangesAsync();


                    return(printJobOrderAfterSave
                        ? RedirectToAction("PrintingJobOrder", "Employee", new { claimId = claim.Id })
                        : RedirectToAction("AbonentClaims", "Employee"));
                }

                ViewData["DictClaimKindId"] =
                    context.DictClaimKind
                    .Where(x => x.IsVisible)
                    .Select(x =>
                            new SelectListItem
                {
                    Text     = x.Name,
                    Value    = x.Id.ToString(),
                    Selected = x.Id == claimViewModel.DictClaimKindId
                }).ToList();

                ViewData["HouseId"] =
                    context.House
                    .Select(x =>
                            new SelectListItem
                {
                    Text     = x.HouseFullAddress,
                    Value    = x.Id.ToString(),
                    Selected = x.Id == claimViewModel.HouseId
                })
                    .OrderBy(x => x.Text)
                    .ToList();

                ViewData["PersonalAccountId"] = context.PersonalAccount
                                                .Where(x => x.HouseId == claimViewModel.HouseId)
                                                .Select(x =>
                                                        new SelectListItem
                {
                    Text     = x.ApartmentFullAddress,
                    Value    = x.Id.ToString(),
                    Selected = x.Id == claimViewModel.PersonalAccountId
                })
                                                .ToList()
                                                .OrderBy(x => x.Text);


                return(View(claimViewModel));
            }
        }
Esempio n. 22
0
        public async Task <IEnumerable <UserViewModel> > GetUserForClaim(ClaimViewModel claimViewModel)
        {
            var claim = _mapper.Map <Claim>(claimViewModel);

            return(await _userManager.GetUsersForClaimAsync(claim));
        }
Esempio n. 23
0
        public async Task <ActionResult> AbonentClaimEdit(
            //    [Bind(Include = "Id,PersonalAccountId,ApartmentFullAddress,DictClaimKindId,Description,ContactPhoneNumber,ClaimStatus,CompleteDate,EmployeeId,OrganizationId,CreationTime,ChangedTime")]
            ClaimViewModel claimViewModel)
        {
            using (var context = new ApplicationDbContext())
            {
                {
                    var claim =
                        await context.AbonentClaim
                        .FirstOrDefaultAsync(
                            x => x.Id == claimViewModel.Id);

                    if (claim == null)
                    {
                        throw new Exception("Заявка не найдена");
                    }

                    if (claimViewModel.ClaimStatus != EClaimStatus.Undefined &&
                        claim.ClaimStatus != claimViewModel.ClaimStatus)
                    {
                        claim.ChangedTime = DateTime.Now;
                        claim.ClaimStatus = claimViewModel.ClaimStatus;
                        //TODO: внести с историю переходов
                    }


                    if (claimViewModel.EmployeeId != null &&
                        claimViewModel.EmployeeId != 0 &&
                        claim.EmployeeId != claimViewModel.EmployeeId)
                    {
                        claim.ChangedTime = DateTime.Now;
                        claim.EmployeeId  = claimViewModel.EmployeeId;
                        //TODO: внести с историю переходов
                    }

                    if (!string.IsNullOrEmpty(claimViewModel.Description) &&
                        claim.Description != claimViewModel.Description)
                    {
                        claim.ChangedTime = DateTime.Now;
                        claim.Description = claimViewModel.Description;
                    }

                    if (claimViewModel.DictClaimKindId != 0 &&
                        claim.DictClaimKindId != claimViewModel.DictClaimKindId)
                    {
                        claim.ChangedTime     = DateTime.Now;
                        claim.DictClaimKindId = claimViewModel.DictClaimKindId;
                    }

                    if (claimViewModel.Cost != null &&
                        claimViewModel.Cost != 0 &&
                        claim.Cost != claimViewModel.Cost)
                    {
                        claim.ChangedTime = DateTime.Now;
                        claim.Cost        = claimViewModel.Cost;
                    }

                    if (!string.IsNullOrEmpty(claimViewModel.ContactPhoneNumber) &&
                        claim.ContactPhoneNumber != claimViewModel.ContactPhoneNumber)
                    {
                        claim.ChangedTime        = DateTime.Now;
                        claim.ContactPhoneNumber = claimViewModel.ContactPhoneNumber;
                    }

                    await context.SaveChangesAsync();

                    return(RedirectToAction("AbonentClaimEdit", "Employee", new { id = claim.Id }));
                }
            }
        }
        public ActionResult SetUserClaim(ClaimViewModel claim, string id)
        {
            try
            {
                UserManager.AddClaimAsync(id, new Claim(claim.Type, claim.Value));

                return RedirectToAction("Details","UsersAdmin", new { id = id });
            }
            catch
            {
                return View();
            }
        }
Esempio n. 25
0
        public FileContentResult GeneratePdf(ClaimViewModel claimViewModel)
        {
            using (var dbContext = new ApplicationDbContext())
            {
                var currentUserId = User.Identity.GetUserId();
                var user          = dbContext.Users.First(u => u.Id == currentUserId);
                user.ClaimNumber++;
                foreach (var pp in claimViewModel.ProfilePriorities)
                {
                    var profilePriorities = dbContext.ProfilePrioritys.Add(new ProfilePriority
                    {
                        Student  = user,
                        Profile  = dbContext.Profiles.First(u => u.Id == pp.Id),
                        Priority = pp.Priority
                    });
                }

                foreach (var cp in claimViewModel.BlockPriorities)
                {
                    var blockPriorities = dbContext.BlockPrioritys.Add(new BlockPriority
                    {
                        Student  = user,
                        Block    = dbContext.Blocks.First(u => u.Id == cp.Id),
                        Priority = cp.Priority
                    });
                }
                //foreach (var pp in claimViewModel.ProfilePriorities)
                //{
                //    var profilePrioritiy = dbContext.ProfilePrioritys.First(p => p.Id == pp.Id);
                //    profilePrioritiy.Priority = pp.Priority;
                //}
                dbContext.SaveChanges();

                var profilePrioritiys = user.ProfilePrioritys.ToList();
                var blockPrioritiys   = user.BlockPrioritys.ToList();
                var templatePath      = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "Заявление шаблон.docx");
                if (user.Direction.Id == 1)
                {
                    templatePath = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "Заявление шаблон090301.docx");
                }
                ;
                if (user.Direction.Id == 2)
                {
                    templatePath = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "Заявление шаблон090303.docx");
                }
                ;
                if (user.Direction.Id == 3)
                {
                    templatePath = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "Заявление шаблон090304.docx");
                }
                ;
                if (user.Direction.Id == 4)
                {
                    templatePath = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), "Заявление шаблон010304.docx");
                }
                ;
                var docId        = Guid.NewGuid().ToString();
                var tempDocxPath = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), $"{docId}.docx");
                var tempPdfPath  = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), $"{docId}.pdf");
                var tempLogPath  = Path.Combine(AppDomain.CurrentDomain.GetData("DataDirectory").ToString(), $"{docId}-log.txt");
                using (var memoryStream = new MemoryStream())
                {
                    var fileBytes = System.IO.File.ReadAllBytes(templatePath);
                    memoryStream.Write(fileBytes, 0, fileBytes.Length);

                    using (WordprocessingDocument doc = WordprocessingDocument.Open(memoryStream, true))
                    {
                        var body  = doc.MainDocumentPart.Document.Body;
                        var texts = body.Descendants <Text>().ToList();

                        //var table = doc.MainDocumentPart.Document.Descendants<Table>().ToList().First();
                        //var i = 1;
                        //var tr1 = new TableRow();
                        //var tc1 = new Word.TableCell();
                        //tc1.Append(new TableCellProperties(new VerticalMerge() { Val = MergedCellValues.Restart }));
                        //var tc2 = new TableCell();
                        //tc2.Append(new TableCellProperties(new VerticalMerge() { Val = MergedCellValues.Continue }));
                        //tr1.Append(tc1,tc2);
                        //table.Append(tr1);
                        // var tr3 = new TableRow();
                        // //tr.Append(new TableRowProperties(new GridAfter() { Val = 2 }));

                        // var Cell1 = new TableCell();
                        //// tr1.Append(new TableRowProperties(new CellMerge() { Val = 2 }));
                        // Cell1.Append(new Paragraph(new Run(new Text("1"))));
                        // var Cell2 = new TableCell();
                        // Cell2.Append(new Paragraph(new Run(new Text("2"))));

                        // tr3.Append(Cell1);
                        // tr2.Append(Cell2);
                        // tr1.Append(tr2)
                        // tr3.Append(tr1, tr2);
                        // table.Append(tr3);
                        //doc.MainDocumentPart.Document.Body.Append(table);


                        //doc.MainDocumentPart.Document.Save();
                        //    table.AppendChild(tr);
                        //foreach (var profilePriority in profilePrioritiys)
                        //{
                        //    var tr = new TableRow();
                        //    tr.Append(new TableRowProperties(new GridAfter() { Val=2}));

                        //    var indexCell = new TableCell();
                        //    //indexCell.Append(new TableCellProperties(new GridSpan() { Val = 2 }));
                        //    indexCell.Append(new Paragraph(new Run(new Text(i.ToString()))));

                        //    var departmentCell = new TableCell();
                        //    departmentCell.Append(new Paragraph(new Run(new Text(profilePriority.Profile.Department.FullName))));

                        //    var profileCell = new TableCell();
                        //    profileCell.Append(new Paragraph(new Run(new Text(profilePriority.Profile.Name))));

                        //    var priorityCell = new TableCell();
                        //    priorityCell.Append(new Paragraph(new Run(new Text(profilePriority.Priority.ToString()))));

                        //    tr.Append(indexCell, departmentCell, profileCell, priorityCell);
                        //    table.AppendChild(tr);
                        //    i++;
                        //}

                        texts.First(t => t.Text == "ФИО").Text                  = string.Format("{0} {1} {2}", user.LastName, user.FirstName, user.Patronymic);
                        texts.First(t => t.Text == "Номер_группы").Text         = user.CurrentGroup.Name;//NewGroup?.Name ?? "";
                        texts.First(t => t.Text == "Номер_направления").Text    = user.Direction.Code;
                        texts.First(t => t.Text == "Название_направления").Text = user.Direction.Name;
                        texts.First(t => t.Text == "Дата_заполнения").Text      = DateTime.Now.ToString("d");
                        if (user.Direction.Id == 1)
                        {
                            texts.First(t => t.Text == "Проф1").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 1).Priority.ToString();
                            texts.First(t => t.Text == "Проф3").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 3).Priority.ToString();
                            texts.First(t => t.Text == "Проф4").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 4).Priority.ToString();
                            texts.First(t => t.Text == "Бл1").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 1).Priority.ToString();
                            texts.First(t => t.Text == "Бл2").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 2).Priority.ToString();
                            texts.First(t => t.Text == "Бл3").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 3).Priority.ToString();
                            texts.First(t => t.Text == "Бл4").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 4).Priority.ToString();
                            texts.First(t => t.Text == "Бл5").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 5).Priority.ToString();
                            texts.First(t => t.Text == "Бл6").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 6).Priority.ToString();
                            texts.First(t => t.Text == "Бл7").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 7).Priority.ToString();
                        }
                        if (user.Direction.Id == 2)
                        {
                            texts.First(t => t.Text == "Проф5").Text  = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 5).Priority.ToString();
                            texts.First(t => t.Text == "Проф10").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 10).Priority.ToString();
                            texts.First(t => t.Text == "Бл8").Text    = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 8).Priority.ToString();
                            texts.First(t => t.Text == "Бл9").Text    = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 9).Priority.ToString();
                            texts.First(t => t.Text == "Бл10").Text   = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 10).Priority.ToString();
                        }
                        if (user.Direction.Id == 3)
                        {
                            texts.First(t => t.Text == "Проф6").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 6).Priority.ToString();
                            texts.First(t => t.Text == "Проф7").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 7).Priority.ToString();
                            texts.First(t => t.Text == "Проф8").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 8).Priority.ToString();
                            texts.First(t => t.Text == "Проф9").Text = user.ProfilePrioritys.First(p => p.Student.Id == user.Id && p.Profile.Id == 9).Priority.ToString();
                            texts.First(t => t.Text == "Бл14").Text  = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 14).Priority.ToString();
                            texts.First(t => t.Text == "Бл15").Text  = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 15).Priority.ToString();
                        }
                        if (user.Direction.Id == 4)
                        {
                            texts.First(t => t.Text == "Бл19").Text = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 19).Priority.ToString();
                            texts.First(t => t.Text == "Бл20").Text = user.BlockPrioritys.First(p => p.Student.Id == user.Id && p.Block.Id == 20).Priority.ToString();
                        }
                    }
                    try
                    {
                        using (FileStream file = new FileStream(tempDocxPath, FileMode.Create, FileAccess.Write))
                        {
                            memoryStream.WriteTo(file);
                        }
                    }
                    catch (Exception ex)
                    {
                        StreamWriter file = new StreamWriter(new FileStream(tempLogPath, FileMode.OpenOrCreate, FileAccess.Write));
                        file.Write(ex.Message);
                        file.Close();
                    }
                }


                if (!System.IO.File.Exists(tempDocxPath))
                {
                    System.Threading.Thread.Sleep(5000);
                }
                try
                {
                    Application appWord      = new Application();
                    var         wordDocument = appWord.Documents.Open(tempDocxPath);
                    wordDocument.ExportAsFixedFormat(tempPdfPath, WdExportFormat.wdExportFormatPDF);
                    appWord.DisplayAlerts = WdAlertLevel.wdAlertsNone;
                    wordDocument.Close();
                    appWord.Quit();
                    if (wordDocument != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(wordDocument);
                    }
                    if (appWord != null)
                    {
                        System.Runtime.InteropServices.Marshal.ReleaseComObject(appWord);
                    }
                    GC.Collect();
                }
                catch (Exception ex)
                {
                    StreamWriter file = new StreamWriter(new FileStream(tempLogPath, FileMode.OpenOrCreate, FileAccess.Write));
                    file.Write(ex.Message);
                    file.Close();
                }



                if (!System.IO.File.Exists(tempPdfPath))
                {
                    System.Threading.Thread.Sleep(2000);
                }



                using (var memoryStream = new MemoryStream())
                {
                    var fileBytes = System.IO.File.ReadAllBytes(tempPdfPath);
                    memoryStream.Write(fileBytes, 0, fileBytes.Length);
                    System.IO.File.Delete(tempDocxPath);
                    System.IO.File.Delete(tempPdfPath);
                    var fileName = string.Format("Заявление №{0}.pdf", user.ClaimNumber);
                    Response.AppendHeader("Content-Disposition", "inline; filename=" + fileName);

                    return(File(fileBytes, "application/pdf"));
                }
            }
        }