Exemple #1
0
        public SupplierParam Get(int?id)
        {
            var           supparam = _context.Supplier.SingleOrDefault(x => x.Id == id && x.IsDelete == false);
            SupplierParam supnew   = new SupplierParam(supparam);

            return(supnew);
        }
 public void Put(int id, SupplierParam supplierparam)
 {
     if (ModelState.IsValid)
     {
         _supplierService.Update(supplierparam);
     }
 }
Exemple #3
0
        //Get Edit
        public ActionResult Edit(int?id)
        {
            var supp      = _supplierService.Get(id);
            var suppParam = new SupplierParam(supp);

            return(View(suppParam));
        }
 public bool Update(int?id, SupplierParam supplierParam)
 {
     if (id == null)
     {
         Console.WriteLine("Please Insert Id");
         Console.Read();
     }
     else if (id.ToString() == " ")
     {
         Console.WriteLine("Dont Insert white space");
         Console.Read();
     }
     else
     {
         if (supplierParam == null)
         {
             Console.WriteLine("Please Insert Supplier");
             Console.Read();
         }
         else if (supplierParam.ToString() == " ")
         {
             Console.WriteLine("Dont Insert white space");
             Console.Read();
         }
         else
         {
             status = _supplierRepository.Update(id, supplierParam);
             Console.WriteLine("Update Successfuly");
             Console.Read();
         }
     }
     return(status);
 }
 public void Post(SupplierParam supplierParam)
 {
     if (ModelState.IsValid)
     {
         _supplierService.Insert(supplierParam);
     }
 }
        public void menuSupplier()
        {
            ISupplierService _supplierService = new SupplierService();
            SupplierParam    supplierParam    = new SupplierParam();

            Console.WriteLine("=========== Supplier Data ============");
            Console.WriteLine("1. Insert");
            Console.WriteLine("2. Update");
            Console.WriteLine("3. Delete");
            Console.WriteLine("4. Retrieve");
            Console.WriteLine("======================================");
            Console.Write("Going to : ");
            int chance = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("======================================");

            switch (chance)
            {
            case 1:
                // ini untuk memasukkan nilai Name, JoinDate, dan CreateDate di Supplier
                Console.Write("Insert Name of Supplier : ");
                supplierParam.Name = Console.ReadLine();
                _supplierService.Insert(supplierParam);
                break;

            case 2:
                // input id untuk dicari
                Console.Write("Insert Id to Update Data : ");
                supplierParam.Id = Convert.ToInt16(Console.ReadLine());

                Console.Write("Insert Name of Supplier : ");
                supplierParam.Name = Console.ReadLine();
                _supplierService.Update(supplierParam.Id, supplierParam);
                break;

            case 3:
                // input id untuk dicari
                Console.Write("Insert Id Supplier : ");
                supplierParam.Id = Convert.ToInt16(Console.ReadLine());
                _supplierService.Delete(supplierParam.Id);
                break;

            case 4:
                _supplierService.Get();
                foreach (var tampilin in _supplierService.Get())
                {
                    Console.WriteLine("=========================================");
                    Console.WriteLine("Name         : " + tampilin.Name);
                    Console.WriteLine("Name         : " + tampilin.JoinDate);
                    Console.WriteLine("=========================================");
                }
                Console.WriteLine("Total Supplier" + _supplierService.Get().Count());
                Console.Read();
                break;

            default:
                Console.Write("Something Wrong, Please try again next time.");
                break;
            }
        }
Exemple #7
0
 public bool Update(int?id, SupplierParam supplierParam)
 {
     if (_supplierRepository.Get(id) == null)
     {
         Console.WriteLine("Sorry, your data is not found");
         Console.Read();
     }
     else if (id.ToString() == " ")
     {
         Console.WriteLine("Don't insert white space");
         Console.Read();
     }
     else
     {
         if (supplierParam.Name.ToString() == " ")
         {
             Console.WriteLine("Don't insert white space");
             Console.Read();
         }
         else
         {
             status = _supplierRepository.Update(id, supplierParam);
         }
     }
     return(status);
 }
Exemple #8
0
        public bool Update(int?id, SupplierParam supplierParam)
        {
            //belum fix
            if (String.IsNullOrWhiteSpace(id.ToString()))
            {
                MessageBox.Show("Please Input ID Correctly");
            }
            else
            {
                var getsupplier = _supplierRepository.Get(id);
                if (getsupplier == null)
                {
                    MessageBox.Show("Id Not Found in Database");
                }
                else
                {
                    if (String.IsNullOrWhiteSpace(supplierParam.Name) == true)
                    {
                        MessageBox.Show("Name Don't Empty");
                    }
                    else
                    {
                        _supplierRepository.Update(id, supplierParam);
                        status = true;
                    }
                }
            }

            return(status);
        }
 public bool Update(int?Id, SupplierParam supplierParam)
 {
     if (Id != null && supplierParam != null)
     {
         status = _supplierRepository.Update(Id, supplierParam);
     }
     return(status);
 }
Exemple #10
0
 public void Put(int id, SupplierParam supplierparam)
 {
     _isupplierservice.Update(supplierparam);
     //var getsupp = context.Suppliers.Find(id);
     //getsupp.Name = supplier.Name;
     //context.Entry(getsupp).State = System.Data.Entity.EntityState.Modified;
     //context.SaveChanges();
 }
 public bool Insert(SupplierParam supplierParam)
 {
     if (supplierParam != null)
     {
         status = _supplierRepository.Insert(supplierParam);
     }
     return(status);
 }
        public void ManageSupplier()
        {
            SupplierParam supplierparam = new SupplierParam();

            Console.WriteLine("========== Manage Supplier ==========");
            Console.WriteLine("1. Insert");
            Console.WriteLine("2. Update");
            Console.WriteLine("3. Delete");
            Console.WriteLine("4. Retrieve");
            Console.WriteLine("=====================================");
            Console.Write("Going to : ");
            int chance = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("=====================================");

            switch (chance)
            {
            case 1:
                Console.Write("Insert Name of Supplier : ");
                supplierparam.Name = Console.ReadLine();
                _supplierService.Insert(supplierparam);
                Console.Read();
                break;

            case 2:
                Console.Write("Insert Id :");
                supplierparam.Id = Convert.ToInt16(Console.ReadLine());
                Console.Write("Insert New Name :");
                supplierparam.Name = Console.ReadLine();
                _supplierService.Update(supplierparam.Id, supplierparam);
                Console.Read();
                break;

            case 3:
                Console.Write("Insert Id of Supplier : ");
                supplierparam.Id = Convert.ToInt16(Console.ReadLine());
                _supplierService.Delete(supplierparam.Id);
                Console.Read();
                break;

            case 4:
                _supplierService.Get();
                foreach (var tampilin in _supplierService.Get())
                {
                    Console.WriteLine("============================");
                    Console.WriteLine("Name      : " + tampilin.Name);
                    Console.WriteLine("Join Date : " + tampilin.JoinDate);
                    Console.WriteLine("============================");
                }
                Console.Write("Total Supplier " + _supplierService.Get().Count);
                Console.Read();
                break;

            default:
                Console.Write("Wrong Number");
                break;
            }
        }
Exemple #13
0
 public ActionResult Update(SupplierParam supplierParam)
 {
     if (ModelState.IsValid)
     {
         _supplierService.Update(supplierParam);
         return(RedirectToAction("Index"));
     }
     return(View(supplierParam));
 }
Exemple #14
0
        public void Update(int id, SupplierParam param)
        {
            var getKecataman = _context.Kecamatans.Find(param.Id_Kecamatan);
            var getKelurahan = _context.Kelurahans.Find(param.Id_Kelurahan);
            var getSupplier  = Get(id);

            getSupplier.Update(param.Name, param.Phone, param.Address, param.PostalCode, getKelurahan, getKecataman, DateTimeOffset.UtcNow.LocalDateTime);
            _context.Entry(getSupplier).State = System.Data.Entity.EntityState.Modified;
            _context.SaveChanges();
        }
        //GET
        public ActionResult Update(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            var supplier = _supplierService.Get(id);
            var supparam = new SupplierParam(supplier);

            return(View(supparam));
        }
        public bool Insert(SupplierParam supplierParam)
        {
            var push = new Supplier(supplierParam);

            _context.Suppliers.Add(push);
            var result = _context.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
Exemple #17
0
 public bool update(int?id, SupplierParam supplierParam)
 {
     if (string.IsNullOrEmpty(id.ToString()) == true)
     {
         Console.WriteLine("id must not be empty");
         Console.Read();
         return(false);
     }
     else
     {
         return(_supplierRepository.update(id, supplierParam));
     }
 }
Exemple #18
0
 public bool Insert(SupplierParam supplierParam)
 {
     if (supplierParam.Name.ToString() == " ")
     {
         Console.WriteLine("Don't insert white space");
         Console.Read();
     }
     else
     {
         status = _supplierRepository.Insert(supplierParam);
     }
     return(status);
 }
        public bool Update(SupplierParam supplierParam)
        {
            var getSupplier = Get(supplierParam.Id);

            getSupplier.Update(supplierParam);
            _context.Entry(getSupplier).State = EntityState.Modified;
            var result = _context.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
        public bool Update(SupplierParam _supplierparam)
        {
            var getSupplier = Get(_supplierparam.Id);

            getSupplier.Update(_supplierparam);
            context.Entry(getSupplier).State = System.Data.Entity.EntityState.Modified;
            var result = context.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
        public bool Update(int?Id, SupplierParam supplierParam)
        {
            var      result   = 0;
            Supplier supplier = Get(Id);

            supplier.Name       = supplierParam.Name;
            supplier.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result = myContext.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
Exemple #22
0
        public bool Update(SupplierParam supplierparam)
        {
            Supplier sup = _context.Supplier.SingleOrDefault(x => x.Id == supplierparam.Id && x.IsDelete == false);

            sup.Update(supplierparam);
            _context.Entry(sup).State = EntityState.Modified;
            var result = _context.SaveChanges();

            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
Exemple #23
0
 public bool Insert(SupplierParam supplierParam)
 {
     if (supplierParam == null)
     {
         Console.WriteLine("Insert Name");
         Console.Read();
     }
     else
     {
         status = _supplierRepository.Insert(supplierParam);
         Console.WriteLine("Success");
     }
     return(status);
 }
Exemple #24
0
 public bool Insert(SupplierParam supplierParam)
 {
     //belum fix
     if (String.IsNullOrWhiteSpace(supplierParam.Name) == true)
     {
         MessageBox.Show("Name Don't Empty");
     }
     else
     {
         _supplierRepository.Insert(supplierParam);
         status = true;
     }
     return(status);
 }
Exemple #25
0
        public bool Update(int?id, SupplierParam supplierParam)
        {
            var       result   = 0;
            Suppliers supplier = Get(id);

            supplier.Name       = supplierParam.Name;
            supplier.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result = _contex.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Update Successfully");
            }
            return(status);
        }
        public bool Insert(SupplierParam supplierParam)
        {
            var result = 0;

            supplier.Name       = supplierParam.Name;
            supplier.JoinDate   = DateTimeOffset.Now.LocalDateTime;
            supplier.CreateDate = DateTimeOffset.Now.LocalDateTime;
            myContext.Suppliers.Add(supplier);
            result = myContext.SaveChanges();
            if (result > 0)
            {
                status = true;
            }
            return(status);
        }
Exemple #27
0
        public bool Update(int?id, SupplierParam supplierParam)
        {
            var result   = 0;
            var supplier = Get(id);

            //var get = _context.Suppliers.Find(id);
            supplier.Name       = supplierParam.Name;
            supplier.UpdateDate = DateTimeOffset.UtcNow.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                return(status = true);
            }
            return(status);
        }
Exemple #28
0
        public IEnumerable <SupplierParam> GetSearch(int typesearch, string name)
        {
            SupplierParam cari = new SupplierParam();

            cari.typesearch = typesearch;
            cari.Name       = name;

            IEnumerable <SupplierParam> listparam = _isupplierservice.GetSearch(cari).Select(x => new SupplierParam
            {
                Id   = x.Id,
                Name = x.Name.ToString(),
                //CreateDate = Convert.ToDateTime(x.CreateDate)
            });

            return(listparam);
        }
Exemple #29
0
        public bool Insert(SupplierParam supplierParam)
        {
            var result   = 0;
            var supplier = new Supplier();

            supplier.Name       = supplierParam.Name;
            supplier.JoinDate   = DateTimeOffset.UtcNow.LocalDateTime;
            supplier.CreateDate = DateTimeOffset.UtcNow.LocalDateTime;
            _context.Suppliers.Add(supplier);
            result = _context.SaveChanges();
            if (result > 0)
            {
                return(status = true);
            }
            return(status);
        }
        public bool Update(int?id, SupplierParam supplierParam)
        {
            var       result   = 0;
            Suppliers supplier = Get(id);

            supplier.Nama       = supplierParam.Name;
            supplier.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                Console.WriteLine("Insert Succesfully");
            }

            return(status);
        }