Example #1
0
        public IActionResult DeleteVendor(string id)
        {
            bool   Status  = false;
            string Message = string.Empty;


            // Finde vendor
            var Vendor = _listOfAll.GetVendorByUserId(id);

            //Vendor With Area
            var VendorWithArea = _listOfAll.GetsVendorWithAreaById(Vendor.Id);

            foreach (var item in VendorWithArea)
            {
                //Delete Driver
                _efRepository.Delete(item);
            }

            //Vendor With Cusine
            var VendorWithCusine = _listOfAll.GetsVendorWithCusineById(Vendor.Id);

            foreach (var item in VendorWithCusine)
            {
                //Delete Driver
                _efRepository.Delete(item);
            }

            //Check Vendor Other Location
            var VendorOtherLocation = _listOfAll.GetOtherLocationByVendorID(Vendor.Id);

            foreach (var item in VendorOtherLocation)
            {
                //Delete Other Location
                _efRepository.Delete(item);
            }


            //Delete Driver
            _efRepository.Delete(Vendor);

            _efRepository.SaveChanges();

            var user   = _userManger.FindByIdAsync(id).Result;
            var result = _userManger.DeleteAsync(user).Result;

            if (result.Succeeded)
            {
                Status  = true;
                Message = "Record Successfully Deleted.";
            }
            else
            {
                Status  = false;
                Message = "Error While Deleted Record.";
            }
            return(Json(new { status = Status, message = Message }));
        }
        public IActionResult Addlocation(int VendorID)
        {
            var otherLocaction             = new OtherLocationVM();
            var getOtherLocationByVendorID = _listOfAll.GetOtherLocationByVendorID(VendorID).ToList();

            otherLocaction.VendorID = VendorID;
            List <OtherLocationList> filllist = new List <OtherLocationList>();

            if (getOtherLocationByVendorID.Count == 0)
            {
                filllist.Add(new OtherLocationList {
                    LocationAddress = "", LocationName = " "
                });
            }

            foreach (var item in getOtherLocationByVendorID)
            {
                filllist.Add(new OtherLocationList()
                {
                    LocationAddress = item.LocationAddress,
                    LocationName    = item.LocationName
                });
            }
            otherLocaction.Lista = filllist;
            return(View("ListofLocation", otherLocaction));
        }