Exemple #1
0
        public async Task <IActionResult> Add([Bind("lineItemID, fileName")] FileAttachment fileAttachment, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (file.Length > 0)
                    {
                        using (var stream = new FileStream(fileAttachment.FileName, FileMode.Create))
                        {
                            await file.CopyToAsync(stream);
                        }
                    }
                    _context.Add(fileAttachment);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Edit", "LineItem"));
                }
                catch (Exception e)
                {
                    _logger.LogError("FileAttachmentsController.Add Error:" + e.GetBaseException());
                    Log.Error("FileAttachmentsController.Add Error:" + e.GetBaseException() + "\n" + e.StackTrace);
                }
            }
            return(View());
        }
        public async Task <IActionResult> Create([Bind("CategoryID,CategoryCode,CategoryName")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("FundID,FundCode,FundDescription")] Fund fund)
        {
            if (ModelState.IsValid)
            {
                _context.Add(fund);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(fund));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("UserID,FirstName,LastName,UserLogin,Email,Phone,ReceiveEmails")] User user)
        {
            if (ModelState.IsValid)
            {
                //user.ReceiveEmails = 1;
                user.UserLogin = user.UserLogin.ToUpper();
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Edit", new { id = user.UserID }));
            }
            return(View(user));
        }
 public async Task <IActionResult> Create([Bind("VendorCode, VendorName")] Vendor vendor, int ContractID)
 {
     if (ModelState.IsValid)
     {
         var oldVendor = _context.Vendors.Where(v => v.VendorCode == vendor.VendorCode);
         // if the vendorcode does not already exist, add the new vendor
         if (oldVendor != null)
         {
             vendor.VendorCode = vendor.VendorCode.ToUpper();
             _context.Add(vendor);
             await _context.SaveChangesAsync();
         }
     }
     return(RedirectToAction("Edit", "Contracts", new { id = ContractID }));
 }