Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,GenderId,Country,NID,Passport,BithCertificate,Image,RankId,Amount,AmountSignId,Description,ManagerSignature,EntryDate")] OthersPayment othersPayment, IFormFile nid, IFormFile profile)
        {
            if (othersPayment.Name != null && othersPayment.GenderId != null && othersPayment.Country != null &&
                othersPayment.RankId != null && othersPayment.Amount != null && othersPayment.AmountSignId != null &&
                othersPayment.Description != null && othersPayment.ManagerSignature != null)
            {
                if (nid.Length > 0)
                {
                    byte[] p1 = null;

                    using (var fs1 = nid.OpenReadStream())
                        using (var ms1 = new MemoryStream())
                        {
                            fs1.CopyTo(ms1);
                            p1 = ms1.ToArray();

                            othersPayment.NID = p1;
                        }
                }
                if (profile.Length > 0)
                {
                    byte[] p1 = null;

                    using (var fs1 = profile.OpenReadStream())
                        using (var ms1 = new MemoryStream())
                        {
                            fs1.CopyTo(ms1);
                            p1 = ms1.ToArray();

                            othersPayment.Image = p1;
                        }
                }

                othersPayment.ManagerSignature = HttpContext.Session.GetString("username");

                _context.Add(othersPayment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            ViewData["AmountSignId"] = new SelectList(_context.AmountSign, "AmountSignId", "AmountSignName", othersPayment.AmountSignId);
            ViewData["GenderId"]     = new SelectList(_context.Gender, "GenderId", "GenderName", othersPayment.GenderId);
            ViewData["RankId"]       = new SelectList(_context.Set <Rank>(), "RankId", "RankName", othersPayment.RankId);
            return(View(othersPayment));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,GenderId,Country,NID,Passport,BithCertificate,Image,RankId,Amount,AmountSignId,Description,ManagerSignature,EntryDate")] OthersPayment othersPayment)
        {
            if (id != othersPayment.Id)
            {
                return(NotFound());
            }

            if (othersPayment.Name != null && othersPayment.GenderId != null && othersPayment.Country != null &&
                othersPayment.RankId != null && othersPayment.Amount != null && othersPayment.AmountSignId != null &&
                othersPayment.Description != null && othersPayment.ManagerSignature != null)
            {
                try
                {
                    othersPayment.ManagerSignature = HttpContext.Session.GetString("username");

                    _context.Update(othersPayment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OthersPaymentExists(othersPayment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AmountSignId"] = new SelectList(_context.AmountSign, "AmountSignId", "AmountSignName", othersPayment.AmountSignId);
            ViewData["GenderId"]     = new SelectList(_context.Gender, "GenderId", "GenderName", othersPayment.GenderId);
            ViewData["RankId"]       = new SelectList(_context.Set <Rank>(), "RankId", "RankName", othersPayment.RankId);
            return(View(othersPayment));
        }