Exemple #1
0
        public async Task <IActionResult> Create([Bind("UserId,Name,LastName,Email")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("AffiliateId,Name,LastName,BirthDate,AdmissionDate,JobPosition,NetSalary")] Affiliate affiliate)
        {
            if (ModelState.IsValid)
            {
                _context.Add(affiliate);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(affiliate));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("CreditTypeId,Name,MonthTerm,Interest")] CreditType creditType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(creditType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(creditType));
        }
        public async Task <IActionResult> Create([Bind("UserTypeId,Type")] UserType userType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(userType));
        }
Exemple #5
0
        public async Task <IActionResult> Create(SavingsViewModel model)
        {
            if (ModelState.IsValid)
            {
                var saving = new Saving
                {
                    Amount = model.Amount,
                    Type   = _context.SavingType.SingleOrDefault(u => u.SavingTypeId == model.SavingTypeId)
                };
                _context.Add(saving);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(model));
        }
        public async Task <IActionResult> Create(CTVModel model)
        {
            Random random = new Random();

            if (ModelState.IsValid)
            {
                var credit = new Credit
                {
                    Affiliate = _context.Affiliates.FirstOrDefault(a => a.AffiliateId == random.Next(2, 12)),
                    Amount    = model.Amount,
                    Purpose   = model.Purpose,
                    State     = 1,
                    Aproved   = false,
                    Type      = _context.CreditType.SingleOrDefault(u => u.CreditTypeId == model.CreditTypeId)
                };
                _context.Add(credit);
                await _context.SaveChangesAsync();

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