コード例 #1
0
        public IActionResult EditUserClaim(ClaimEditModel model)
        {
            model.Update();
            if (ModelState.IsValid)
            {
                using (var uow = _identityDataService.StartUnitOfWork())
                {
                    var user = uow.UserRepository.Get(model.UserId);

                    var existing = uow.ClaimRepository.GetByUser(user).SingleOrDefault(c => c.Type == model.Type);
                    if (existing == null)
                    {
                        return(View("Error"));
                    }

                    existing.Value = model.Value;
                    uow.ClaimRepository.Update(existing);

                    uow.Commit();
                    model.UpdateSuccess();
                }
            }

            return(View(model));
        }
コード例 #2
0
        protected override async Task OnInitializedAsync()
        {
            CreateEditMode = false;
            ClaimEditModel = new ClaimEditModel();
            Claims         = (await ClaimService.GetClaims()).ToList();

            //Categories = (await CategoryService.GetCategories()).ToList();
            //CategoryId = Claim.CategoryId.ToString();
            //Currencies = (await CurrencyService.GetCurrencies()).ToList();
            //CurrencyId = Claim.CurrencyId.ToString();
        }
コード例 #3
0
        protected ImageConverter _imageConverter;// = new ImageConverter();

        protected override async Task OnInitializedAsync()
        {
            var authenticationState     = await((CustomAuthenticationStateProvider)AuthenticationStateProvider).GetAuthenticationStateAsync();
            var AuthenticationStateUser = authenticationState.User;

            Name = AuthenticationStateUser.Claims.Where(x => x.Type.Equals("email")).FirstOrDefault().Value;
            if (Name == null)
            {
                Name = (await authenticationStateTask).User.Claims.Where(x => x.Type.Equals("email")).FirstOrDefault().Value;
            }
            if (!authenticationState.User.Identity.IsAuthenticated)
            {
                string returnUrl = WebUtility.UrlEncode($"/list");
                NavigationManager.NavigateTo($"/login?returnUrl={returnUrl}");
            }

            Categories = (await CategoryService.GetCategories()).ToList();
            Currencies = (await CurrencyService.GetCurrencies()).ToList();

            //Id = Id ?? "1";
            int.TryParse(Id, out int claimId);
            if (claimId != 0)// for Edit
            {
                Claim = (await ClaimService.GetClaimById(int.Parse(Id)));
                Mapper.Map(Claim, ClaimEditModel);

                if (ClaimEditModel.RequesterComments != null)
                {
                    RequesterComments = ClaimEditModel.RequesterComments;
                }
                if (ClaimEditModel.ApproverComments != null)
                {
                    ApproverComments = ClaimEditModel.ApproverComments;
                }
                if (ClaimEditModel.FinanceComments != null)
                {
                    FinanceComments = ClaimEditModel.FinanceComments;
                }

                if (Claim.LineItems.Count() > 0)
                {
                    foreach (var LineItem in Claim.LineItems)
                    {
                        LineItemEditModel = new LineItemEditModel();
                        Mapper.Map(LineItem, LineItemEditModel);
                        LineItemEditModels.Add(LineItemEditModel);
                        if (LineItem.Receipt != null)
                        {
                            imageDataUrls.Clear();
                            var format       = "image/png";
                            var imageDataUrl = $"data:{format};base64,{Convert.ToBase64String(LineItem.Receipt)}";
                            imageDataUrls.Add(imageDataUrl);

                            LineItemImageModel Lim = new LineItemImageModel {
                                Id = LineItem.Id, ImageDataUrls = imageDataUrls.ToList()
                            };
                            LineItemImageModels.Add(Lim);
                        }
                    }
                }
            }
            else // for Create
            {
                ClaimEditModel = new ClaimEditModel
                {
                    Requester  = Name,
                    SubmitDate = DateTime.Now,
                    Status     = (Status)Enum.Parse(typeof(Status), "Requested")
                };
                if (LineItemEditModels.Count() > 0)
                {
                    foreach (var lineItemEditModel in LineItemEditModels)
                    {
                        if (lineItemEditModel.Receipt != null)
                        {
                            imageDataUrls.Clear();
                            var format       = "image/png";
                            var imageDataUrl = $"data:{format};base64,{Convert.ToBase64String(lineItemEditModel.Receipt)}";
                            imageDataUrls.Add(imageDataUrl);
                            LineItemImageModel Lim = new LineItemImageModel {
                                Id = lineItemEditModel.Id, ImageDataUrls = imageDataUrls.ToList()
                            };
                            LineItemImageModels.Add(Lim);
                        }
                    }
                }
            }
        }
コード例 #4
0
 protected async Task Create_Click()
 {
     CreateEditMode = true;
     ClaimEditModel = new ClaimEditModel();
 }