Esempio n. 1
0
        public async Task <IActionResult> Supplier(string id)
        {
            var user = await _userManager.GetUserAsync(User);

            if (User == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (id == null)
            {
                ViewData["_Save"]   = "True";
                ViewData["_Update"] = "False";
                TXSSupplierDetailView obj = new TXSSupplierDetailView();
                obj.master.SupActive = (obj.master.SupActive == null) ? true : false;
                obj.lstCountry       = db.TxscountryDetail.ToList();
                return(PartialView(obj));
            }
            else
            {
                ViewData["_Save"]   = "False";
                ViewData["_Update"] = "True";
                TXSSupplierDetailView obj = new TXSSupplierDetailView();
                obj.lstCountry       = db.TxscountryDetail.ToList();
                obj.master           = db.TxssupplierDetail.Where(x => x.Id == user.Id && x.UserName == user.UserName && x.SupId == Convert.ToInt32(id)).FirstOrDefault();
                obj.master.SupActive = (obj.master.SupActive == true) ? true : false;
                obj.lstCity          = db.TxscityDetail.Where(x => x.CouCode == obj.master.SupCountry).ToList();
                return(PartialView(obj));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Supplier(TXSSupplierDetailView obj, string Save, string Update, string SupActive)
        {
            var user = await _userManager.GetUserAsync(User);

            if (User == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }
            if (Save != null)
            {
                obj.master.Id        = user.Id;
                obj.master.UserName  = user.UserName;
                obj.master.SupActive = (SupActive == "true") ? true : false;
                obj.master.EnterBy   = user.UserName;
                obj.master.EnterDate = System.DateTime.Now;
                db.TxssupplierDetail.Add(obj.master);
                db.SaveChanges();
            }
            if (Update != null)
            {
                TxssupplierDetail obj1 = new TxssupplierDetail();
                obj1 = db.TxssupplierDetail.Where(x => x.Id == user.Id && x.UserName == user.UserName && x.SupId == obj.master.SupId).FirstOrDefault();
                if (obj1 != null)
                {
                    obj1.SupType    = obj.master.SupType;
                    obj1.SupName    = obj.master.SupName;
                    obj1.SupAbbr    = obj.master.SupAbbr;
                    obj1.SupPerson  = obj.master.SupPerson;
                    obj1.SupAddress = obj.master.SupAddress;
                    obj1.SupPhNo    = obj.master.SupPhNo;
                    obj1.SupFaxNo   = obj.master.SupFaxNo;
                    obj1.SupEmail   = obj.master.SupEmail;
                    obj1.SupNtn     = obj.master.SupNtn;
                    obj1.SupStrn    = obj.master.SupStrn;
                    obj1.SupCity    = obj.master.SupCity;
                    obj1.SupCountry = obj.master.SupCountry;
                    obj1.SupDesc    = obj.master.SupDesc;
                    obj1.SupCrDays  = obj.master.SupCrDays;
                    obj1.SupActive  = (SupActive == "true") ? true : false;
                    obj1.EditBy     = user.UserName;
                    obj1.EditDate   = System.DateTime.Now;
                    db.SaveChanges();
                }
            }
            return(RedirectToAction("showSupplier"));
        }