public ActionResult EditSup(SupplierModel supplier)
        {
            foreach (SUPPLIER_PHONE phone in supplier.Phones.ToList())
            {
                if (phone.DeletePhone == true)
                {
                    // Delete Phone Numbers which is marked to remove
                    supplier.Phones.Remove(phone);
                }
                if (phone.Phone == null)
                {
                    // Delete Phone Numbers When Phone = null
                    supplier.Phones.Remove(phone);
                }
            }

            //เช็ค เบอร์ซ้ำ
            List <SUPPLIER_PHONE> pList = new List <SUPPLIER_PHONE>(supplier.Phones);

            for (int i = 0; i < pList.Count; i++)
            {
                for (int j = 0; j < pList.Count; j++)
                {
                    if (pList[i].Phone.Equals(pList[j].Phone) && i != j)
                    {
                        ModelState.AddModelError("", "Please complete the following information,Phone Number Fail.");
                        return(View(supplier));
                    }
                }
            }
            if (_supRepository.UpdateSupplier(Mapper.ToDto(supplier), supplier.Phones.ToList()) == false)
            {
                ModelState.AddModelError("", "Please complete the following information,Phone Number Fail.");
                return(View(supplier));
            }
            return(RedirectToAction("ListSup", "Supplier"));
        }
Exemple #2
0
 public virtual void UpdateSupplier(Supplier entity)
 {
     entityDao.UpdateSupplier(entity);
 }