//
        // GET: /BuyVendor/Edit/5

        public IActionResult Edit(string id = null)
        {
            BuyVendorModel buyvendor = new BuyVendorModel();

            buyvendor.DocId = id;
            return(PartialView(buyvendor));
        }
        public async Task <IViewComponentResult> InvokeAsync(string id = null)
        {
            BuyVendorModel buyvendor = new BuyVendorModel();

            buyvendor.DocId = id;
            return(View(buyvendor));
        }
        public IActionResult DeleteConfirmed(string id)
        {
            BuyVendorModel buyvendor = _context.BuyVendors.Find(id);

            _context.BuyVendors.Remove(buyvendor);
            _context.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //
        // GET: /BuyVendor/Details/5

        public IActionResult Details(string id = null)
        {
            BuyVendorModel buyvendor = _context.BuyVendors.Find(id);

            if (buyvendor == null)
            {
                return(NotFound());
            }
            return(View(buyvendor));
        }
        public IActionResult Create(BuyVendorModel buyvendor)
        {
            if (ModelState.IsValid)
            {
                _context.BuyVendors.Add(buyvendor);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(buyvendor));
        }
 public IActionResult Edit(BuyVendorModel buyvendor)
 {
     if (ModelState.IsValid)
     {
         // Get Login User's details.
         var loginUser = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault();
         buyvendor.Status = "?";
         buyvendor.Rtp    = loginUser.Id.ToString();
         buyvendor.Rtt    = DateTime.Now;
         _context.BuyVendors.Add(buyvendor);
         _context.SaveChanges();
         List <BuyVendorModel> rf = _context.BuyVendors.Where(f => f.DocId == buyvendor.DocId).ToList();
         return(PartialView("Index", rf));
     }
     return(View(buyvendor));
 }
Beispiel #7
0
        public async Task <IViewComponentResult> InvokeAsync(string id = null, string typ = null, string uniteno = null)
        {
            List <AttainFileModel> af  = new List <AttainFileModel>();
            List <AttainFileModel> af2 = new List <AttainFileModel>();

            if (id != null)
            {
                AppUserModel u;
                int          uno = Convert.ToInt32(uniteno);
                af = _context.BMEDAttainFiles.Where(f => f.DocType == typ).Where(f => f.DocId == id).ToList();
                foreach (AttainFileModel a in af)
                {
                    if (a.DocType == "3" && (a.Rtp == uno || a.IsPublic == "Y"))
                    {
                        BuyVendorModel b = _context.BuyVendors.Find(a.DocId, a.Rtp);
                        if (b != null)
                        {
                            a.UserName = b.VendorNam;
                        }
                        else
                        {
                            if (a.Rtp != null)
                            {
                                u          = _context.AppUsers.Find(a.Rtp);
                                a.UserName = u.FullName;
                            }
                        }
                        af2.Add(a);
                    }
                }
            }
            else
            {
                AppUserModel u;
                af = _context.BMEDAttainFiles.ToList();
                foreach (AttainFileModel a in af)
                {
                    if (a.Rtp != null)
                    {
                        u          = _context.AppUsers.Find(a.Rtp);
                        a.UserName = u.FullName;
                    }
                }
            }
            return(View(af2));
        }
        public IActionResult Upload(string id = null, string vno = null)
        {
            BuyVendorModel buyvendor = _context.BuyVendors.Find(id, vno);

            buyvendor.Status = "2";
            buyvendor.Rtp    = vno;
            buyvendor.Rtt    = DateTime.Now;
            _context.Entry(buyvendor).State = EntityState.Modified;
            try
            {
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(RedirectToAction("BuyPriceList", "BuyVendor", new { uniteno = buyvendor.UniteNo }));
        }
        //
        // GET: /BuyVendor/Delete/5

        public IActionResult Delete(string id = null, string vno = null)
        {
            BuyVendorModel buyvendor = _context.BuyVendors.Find(id, vno);

            if (buyvendor == null)
            {
                return(NotFound());
            }
            _context.BuyVendors.Remove(buyvendor);
            try
            {
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(new JsonResult(buyvendor)
            {
                Value = new { success = true, error = "" },
            });
        }
        public IActionResult UpdStatus(string id = null, string vno = null)
        {
            // Get Login User's details.
            var            loginUser = _userRepo.Find(ur => ur.UserName == User.Identity.Name).FirstOrDefault();
            BuyVendorModel buyvendor = _context.BuyVendors.Find(id, vno);

            buyvendor.Status = "?";
            buyvendor.Rtp    = loginUser.Id.ToString();
            buyvendor.Rtt    = DateTime.Now;
            _context.Entry(buyvendor).State = EntityState.Modified;
            try
            {
                _context.SaveChanges();
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(new JsonResult(buyvendor)
            {
                Value = new { success = true, error = "" },
            });
        }