Beispiel #1
0
        public List <SuppliersVM> MakeSupplierVM(string suppType)
        {
            var preModel = new List <CarDealer.Models.Supplier>();

            if (suppType == "Local")
            {
                preModel = Contex.Suppliers.Where(x => x.IsImporter == false).ToList();
            }
            else if (suppType == "Importers")
            {
                preModel = Contex.Suppliers.Where(x => x.IsImporter == true).ToList();
            }
            else
            {
                preModel = Contex.Suppliers.ToList();
            }

            var model = new List <SuppliersVM>();

            foreach (var pre in preModel)
            {
                var temp = new SuppliersVM();
                temp.Id            = pre.Id;
                temp.Name          = pre.Name;
                temp.NumberOfParts = pre.Parts.Count;
                model.Add(temp);
            }
            return(model);
        }
Beispiel #2
0
 public MainVM()
 {
     Customer             = new CustomersVM();
     Supplier             = new SuppliersVM();
     SelectedMain         = Customer;
     _content             = new CustomerSettings();
     _content.DataContext = Customer;
     SettingsControl      = _content;
 }
        public ActionResult CreateSupplier([FromBody] SuppliersVM vM)
        {
            var exists = repo.GetAll().Where(x => x.RecipientCode == vM.RecipientCode).ToList();

            if (exists == null)
            {
                var manager = new SupplierManager(repo);
                manager.CreateSupplier(vM);
                return(Ok());
            }
            return(Ok());
        }
Beispiel #4
0
        // GET: Supliers
        public ActionResult Index()
        {
            var preModel = this.service.Contex.Suppliers.ToList();

            var model = new List <SuppliersVM>();

            foreach (var pre in preModel)
            {
                var temp = new SuppliersVM();
                temp.Id            = pre.Id;
                temp.Name          = pre.Name;
                temp.NumberOfParts = pre.Parts.Count;
                model.Add(temp);
            }

            return(View(model));
        }
Beispiel #5
0
        public JsonResult SuppliersSaveData(SuppliersVM supplierVm)
        {
            var isEdit = supplierVm.Supplier.SupplierId > 0;

            var obj = new Supplier();

            if (isEdit)
            {
                obj = _SupplierBusiness.SelectOneById(supplierVm.Supplier.SupplierId);
            }


            obj.Name = supplierVm.Supplier.Name;



            if (isEdit)
            {
                _SupplierBusiness.Update(obj);
            }
            else
            {
                var success = _SupplierBusiness.Create(obj);

                if (success)
                {
                    return(Json(new DefaultReturnVM()
                    {
                        NewCreatedId = obj.SupplierId
                    }));
                }
                else
                {
                    return(Json(new DefaultReturnVM()
                    {
                        ValidationError = "Error creating Supplier"
                    }));
                }
            }



            return(Json(true));
        }
Beispiel #6
0
        public ActionResult Index(int id = 0)
        {
            var model = new SuppliersVM();


            if (id > 0)
            {
                model.Supplier = _SupplierBusiness.SelectOneById(id);
            }
            else
            {
                model.Supplier = new Supplier();
            }

            model.Suppliers = _SupplierBusiness.Select().OrderBy(a => a.Name);


            return(View(model));
        }
        public dynamic PutSupplier(SuppliersVM s)
        {
            var supplier = db.Suppliers.Find(s.Id);

            supplier.NameAr   = s.NameAr;
            supplier.NameEn   = s.NameEn;
            supplier.Phone    = s.phone;
            supplier.Mobile   = s.Mobile;
            supplier.Email    = s.Email;
            supplier.Address  = s.Address;
            supplier.CityId   = s.CityId;
            supplier.RegionId = s.RegionId;
            var result = db.SaveChanges() > 0 ? true : false;

            return(new
            {
                result = result
            });
        }
        public dynamic PostSupplier(SuppliersVM s)
        {
            db.Suppliers.Add(new Supplier
            {
                NameAr   = s.NameAr,
                NameEn   = s.NameEn,
                Phone    = s.phone,
                Mobile   = s.Mobile,
                Email    = s.Email,
                Address  = s.Address,
                CityId   = s.CityId,
                RegionId = s.RegionId
            });
            var result = db.SaveChanges() > 0 ? true : false;

            return(new
            {
                result = result
            });
        }
Beispiel #9
0
        public void CreateSupplier(SuppliersVM model)
        {
            var entity = model.Create();

            repo.Add(entity);
        }
Beispiel #10
0
 private void Suppliers_Click(object sender, RoutedEventArgs e)
 {
     DataContext = new SuppliersVM();
 }