Beispiel #1
0
        public customerContactController()
        {
            repo     = RepositoryHelper.Get客戶聯絡人Repository();
            occuRepo = RepositoryHelper.Get客戶聯絡人Repository(repo.UnitOfWork);

            repo客戶資料 = RepositoryHelper.Get客戶資料Repository();
        }
        public 客戶資料Controller()
        {
            this.repo        = RepositoryHelper.Get客戶資料Repository();
            this.contactRepo = RepositoryHelper.Get客戶聯絡人Repository(repo.UnitOfWork);

            CreateCategoryDic();
        }
        public 客戶資料Controller()
        {
            //要用Helper啦

            rep    = RepositoryHelper.Get客戶資料Repository();
            rep聯絡人 = RepositoryHelper.Get客戶聯絡人Repository(rep.UnitOfWork);
        }
Beispiel #4
0
        public 客戶聯絡人Controller()
        {
            var unitOfWork = new EFUnitOfWork();

            customerContactRepo = RepositoryHelper.Get客戶聯絡人Repository(unitOfWork);
            customerRepo        = RepositoryHelper.Get客戶資料Repository(unitOfWork);
        }
Beispiel #5
0
 public 客戶資料Controller()
 {
     repo         = RepositoryHelper.Get客戶資料Repository();
     bankRepo     = RepositoryHelper.Get客戶銀行資訊Repository(repo.UnitOfWork);
     contactRepo  = RepositoryHelper.Get客戶聯絡人Repository(repo.UnitOfWork);
     categoryRepo = RepositoryHelper.Get客戶類別Repository(repo.UnitOfWork);
 }
Beispiel #6
0
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            PropertyInfo custProp = validationContext.ObjectType.GetProperty(this._field);

            var oCustId = custProp.GetValue(validationContext.ObjectInstance, null);

            int iCustId = Convert.ToInt32(oCustId);

            string sValue;

            sValue = Convert.ToString(value);

            客戶聯絡人Repository custContactRepo = RepositoryHelper.Get客戶聯絡人Repository();

            var data = custContactRepo.All().AsQueryable();

            data = data.Where(p => p.客戶Id == iCustId && p.Email == sValue);

            if (data.Count() > 0)
            {
                return(new ValidationResult("Email Address重複!!"));
            }
            else
            {
                return(null);
            }


            //   return base.IsValid(value, validationContext);
        }
        public static 客戶聯絡人Repository Get客戶聯絡人Repository(IUnitOfWork unitOfWork)
        {
            var repository = new 客戶聯絡人Repository();

            repository.UnitOfWork = unitOfWork;
            return(repository);
        }
        public static 客戶聯絡人Repository Get客戶聯絡人Repository()
        {
            var repository = new 客戶聯絡人Repository();

            repository.UnitOfWork = GetUnitOfWork();
            return(repository);
        }
        public HomeController()
        {
            var unitOfWork = new EFUnitOfWork();

            customerManagementListRepo = RepositoryHelper.Get客戶管理清單Repository(unitOfWork);
            customerContactRepo        = RepositoryHelper.Get客戶聯絡人Repository(unitOfWork);
            customerRepo = RepositoryHelper.Get客戶資料Repository(unitOfWork);
        }
        public ActionResult 客戶聯絡人Excel()
        {
            客戶聯絡人Repository repo  = RepositoryHelper.Get客戶聯絡人Repository();
            List <客戶聯絡人>    items = repo.All().ToList();
            var             dt    = ConvertToDataTable(items);

            ExportExcel(dt, "客戶聯絡人");
            return(RedirectToAction("客戶聯絡人Excel", "File"));
        }
Beispiel #11
0
        public ActionResult ContactCount(int?cid)
        {
            客戶聯絡人Repository repo = RepositoryHelper.Get客戶聯絡人Repository();
            var             聯絡人  = repo.All();

            聯絡人 = 聯絡人.Where(r => r.客戶Id == cid);

            return(Json(new
            {
                isOK = true,
                count = 聯絡人.Count()
            }, JsonRequestBehavior.AllowGet));
        }
        public override bool IsValid(object value)
        {
            客戶聯絡人Repository db = RepositoryHelper.Get客戶聯絡人Repository();

            if (db.檢查同一個客戶下的聯絡人電子郵件不可重複(this.客戶ID, this.MyEmail))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #13
0
        public void Initialze()
        {
            contacts = new List <客戶聯絡人>
            {
                new 客戶聯絡人 {
                    Id = 0, 姓名 = "test0", 是否已刪除 = false, 客戶資料 = new 客戶資料 {
                        Id = 0, 客戶名稱 = "test0", Email = "*****@*****.**", 是否已刪除 = false
                    }
                },
                new 客戶聯絡人 {
                    Id = 1, 姓名 = "test1", 是否已刪除 = false, 客戶資料 = new 客戶資料 {
                        Id = 1, 客戶名稱 = "test1", Email = "*****@*****.**", 是否已刪除 = false
                    }
                },
                new 客戶聯絡人 {
                    Id = 2, 姓名 = "test2", 是否已刪除 = false, 客戶資料 = new 客戶資料 {
                        Id = 2, 客戶名稱 = "test2", Email = "*****@*****.**", 是否已刪除 = false
                    }
                },
                new 客戶聯絡人 {
                    Id = 3, 姓名 = "test3", 是否已刪除 = false, 客戶資料 = new 客戶資料 {
                        Id = 3, 客戶名稱 = "test3", Email = "*****@*****.**", 是否已刪除 = false
                    }
                }
            }.AsQueryable();

            mockDbSet = Substitute.For <DbSet <客戶聯絡人>, IDbSet <客戶聯絡人> >();
            mockDbSet.Provider.Returns(contacts.Provider);
            mockDbSet.Expression.Returns(contacts.Expression);
            mockDbSet.ElementType.Returns(contacts.ElementType);
            mockDbSet.GetEnumerator().Returns(contacts.GetEnumerator());

            mockDbSet.Find(Arg.Any <int>()).Returns(callinfo =>
            {
                var idValues = callinfo.Arg <object[]>();
                int id       = (int)idValues[0];
                return(contacts.SingleOrDefault(c => c.Id == id));
            });

            mockDbSet.Include("test").ReturnsForAnyArgs(mockDbSet);

            mockDBContext = Substitute.For <客戶資料DBEntities>();
            mockDBContext.客戶聯絡人.Returns(mockDbSet);

            mockRepo = Substitute.For <客戶聯絡人Repository>();
            mockRepo.All().Returns(contacts.Where(contact => contact.是否已刪除 == false));
            mockRepo.UnitOfWork = Substitute.For <IUnitOfWork>();
        }
Beispiel #14
0
        public static List <SelectListItem> GetJobTitle()
        {
            客戶聯絡人Repository CCRepo = RepositoryHelper.Get客戶聯絡人Repository();
            var             list   = new List <SelectListItem>();
            var             data   = CCRepo.All();

            list.Add(new SelectListItem {
                Text = "全部", Value = ""
            });
            foreach (var item in data)
            {
                list.Add(new SelectListItem {
                    Text = item.職稱, Value = item.職稱
                });
            }

            return(list);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            //客戶資料 客戶資料 = db.客戶資料.Find(id);
            //客戶資料.是否已刪除 = true;
            ////db.客戶資料.Remove(客戶資料);
            //db.SaveChanges();

            客戶聯絡人Repository repoC = new 客戶聯絡人Repository();
            repoC.DeleteRange(repoC.All().Where(c => c.客戶Id == id));
            repoC.UnitOfWork.Commit();

            客戶銀行資訊Repository repoB = new 客戶銀行資訊Repository();
            repoB.DeleteRange(repoB.All().Where(c => c.客戶Id == id));
            repoB.UnitOfWork.Commit();

            repo.Delete(repo.Find(id));
            repo.UnitOfWork.Commit();
            return RedirectToAction("Index");
        }
Beispiel #16
0
        public ActionResult DeleteConfirmed(int id)
        {
            //客戶資料 客戶資料 = db.客戶資料.Find(id);
            //客戶資料.是否已刪除 = true;
            ////db.客戶資料.Remove(客戶資料);
            //db.SaveChanges();

            客戶聯絡人Repository repoC = new 客戶聯絡人Repository();

            repoC.DeleteRange(repoC.All().Where(c => c.客戶Id == id));
            repoC.UnitOfWork.Commit();

            客戶銀行資訊Repository repoB = new 客戶銀行資訊Repository();

            repoB.DeleteRange(repoB.All().Where(c => c.客戶Id == id));
            repoB.UnitOfWork.Commit();

            repo.Delete(repo.Find(id));
            repo.UnitOfWork.Commit();
            return(RedirectToAction("Index"));
        }
        public ActionResult 聯絡人Details(int id, 客戶聯絡人[] 聯絡人data)
        {
            客戶聯絡人Repository 聯絡人repo = RepositoryHelper.Get客戶聯絡人Repository();

            if (ModelState.IsValid)
            {
                foreach (var item in 聯絡人data)
                {
                    var oldData = 聯絡人repo.Find(item.Id);
                    oldData.職稱 = item.職稱;
                    oldData.手機 = item.手機;
                    oldData.電話 = item.電話;
                }
                聯絡人repo.UnitOfWork.Commit();

                return(RedirectToAction("Details", new { id = id }));
            }

            var data = repo.Find(id);

            return(View("Details", data));
        }
Beispiel #18
0
        public ActionResult Edit(IList <BatchUpdateContact> data,
                                 [Bind(Include = "Id,客戶名稱,統一編號,電話,傳真,地址,Email,是否已刪除,類別Id")] 客戶資料 客戶資料)
        {
            if (ModelState.IsValid)
            {
                #region 原程式碼,不使用Repository時的方法,有東西沒搞懂,先Mark起來

                /*
                 * db.Entry(客戶資料).State = EntityState.Modified;
                 * db.SaveChanges();
                 * return RedirectToAction("Index");
                 *
                 */
                #endregion


                客戶聯絡人Repository repoContactForCommitWithCust = RepositoryHelper.Get客戶聯絡人Repository(repoCust.UnitOfWork);
                if (data != null)
                {
                    foreach (var item in data)
                    {
                        var contact = repoContactForCommitWithCust.Find(item.Id);
                        if (contact != null)
                        {
                            contact.職稱 = item.職稱;
                            contact.手機 = item.手機;
                            contact.電話 = item.電話;
                        }
                    }
                }
                repoCust.UnitOfWork.Context.Entry(客戶資料).State = EntityState.Modified;
                repoContactForCommitWithCust.UnitOfWork.Commit();
                return(RedirectToAction("Index"));
            }
            return(View(客戶資料));
        }
 public 客戶聯絡人Controller()
 {
     repo聯絡 = RepositoryHelper.Get客戶聯絡人Repository();
     repo客戶 = RepositoryHelper.Get客戶資料Repository(repo聯絡.UnitOfWork);
 }
 public CustomerContactController()
 {
     repo = RepositoryHelper.Get客戶聯絡人Repository();
 }
Beispiel #21
0
 public 客戶聯絡人Controller()
 {
     ClientData    = RepositoryHelper.Get客戶資料Repository();
     ClientContact = RepositoryHelper.Get客戶聯絡人Repository(ClientData.UnitOfWork);
     ClientBank    = RepositoryHelper.Get客戶銀行資訊Repository(ClientContact.UnitOfWork);
 }
Beispiel #22
0
 public 客戶聯絡人Controller()
 {
     CCRepo = RepositoryHelper.Get客戶聯絡人Repository(unitOfWork);
     CRepo  = RepositoryHelper.Get客戶資料Repository(unitOfWork);
 }
 public CustomerInfoManageController()
 {
     客戶聯絡人repo = RepositoryHelper.Get客戶聯絡人Repository(客戶資料repo.UnitOfWork);
 }
 public CustomerContactPersonController()
 {
     customerContactPerson = RepositoryHelper.Get客戶聯絡人Repository();
     customer = RepositoryHelper.Get客戶資料Repository();
 }
 public 客戶聯絡人Controller()
 {
     repo         = RepositoryHelper.Get客戶聯絡人Repository();
     repoCustomer = RepositoryHelper.Get客戶資料Repository();
 }
 public ContactsController()
 {
     contactRepo  = RepositoryHelper.Get客戶聯絡人Repository();
     customerRepo = RepositoryHelper.Get客戶資料Repository(contactRepo.UnitOfWork);
 }
 public ContactController()
 {
     this._ContactRepo = RepositoryHelper.Get客戶聯絡人Repository();
     this._CustomerInfoRepo = RepositoryHelper.Get客戶資料Repository();
 }
 public static 客戶聯絡人Repository Get客戶聯絡人Repository()
 {
     var repository = new 客戶聯絡人Repository();
     repository.UnitOfWork = GetUnitOfWork();
     return repository;
 }
 public static 客戶聯絡人Repository Get客戶聯絡人Repository(IUnitOfWork unitOfWork)
 {
     var repository = new 客戶聯絡人Repository();
     repository.UnitOfWork = unitOfWork;
     return repository;
 }
 public 客戶聯絡人Controller()
 {
     repo   = RepositoryHelper.Get客戶聯絡人Repository();
     custpo = RepositoryHelper.Get客戶資料Repository(repo.UnitOfWork);
     //  occuRepo = RepositoryHelper.Get客戶資料Repository(repo.UnitOfWork);
 }
 public 客戶聯絡人Controller()
 {
     repo = RepositoryHelper.Get客戶聯絡人Repository();
 }
Beispiel #32
0
 public ContactController()
 {
     repo     = RepositoryHelper.Get客戶聯絡人Repository();
     repoCust = RepositoryHelper.Get客戶資料Repository(repo.UnitOfWork);
 }
 public 客戶資料Controller()
 {
     repo客戶清單  = RepositoryHelper.Get客戶清單Repository(repo客戶資料.UnitOfWork);
     repo客戶聯絡人 = RepositoryHelper.Get客戶聯絡人Repository(repo客戶資料.UnitOfWork);
 }
Beispiel #34
0
 public 客戶資料Controller()
 {
     repoCustomer = RepositoryHelper.Get客戶資料Repository();
     repoBank     = RepositoryHelper.Get客戶銀行資訊Repository(repoCustomer.UnitOfWork);
     repoContact  = RepositoryHelper.Get客戶聯絡人Repository(repoCustomer.UnitOfWork);
 }