public TXSSupplierDetailView()
 {
     master     = new TxssupplierDetail();
     lstCountry = new List <TxscountryDetail>();
     lstCity    = new List <TxscityDetail>();
     lstAccount = new List <Txscoadetail>();
 }
Example #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"));
        }