コード例 #1
0
ファイル: ContactManager.cs プロジェクト: LooWooTech/SCM
 private bool Validate(Contact contact)
 {
     using (var db = GetDataContext())
     {
         var entity = db.Contacts.FirstOrDefault(e => e.Name.ToUpper() == contact.Name.ToUpper()&&e.sex==contact.sex);
         return entity == null ? true : false;
     }
 }
コード例 #2
0
ファイル: ContactManager.cs プロジェクト: LooWooTech/SCM
 public int Add(Contact contact)
 {
     if (!Validate(contact))
     {
         throw new ArgumentException("存在相同信息的联系人");
     }
     using (var db = GetDataContext())
     {
         db.Contacts.Add(contact);
         db.SaveChanges();
         return contact.ID;
     }
 }
コード例 #3
0
ファイル: ContactController.cs プロジェクト: LooWooTech/SCM
        public ActionResult Add(Contact contact)
        {
            if (ModelState.IsValid)
            {
                var Index = Core.ContactManager.Add(contact);
                if (Index > 0)
                {
                    var list = Core.AddressListManager.Acquire(HttpContext, Index);
                    Core.AddressListManager.Add(list);
                }
            }
            var entity = Core.EnterpriseManager.Get(contact.EID);
            if (entity == null)
            {
                throw new ArgumentException("未找到企业信息");
            }

            return RedirectToAction("Index", "Enterprise", new { business = entity.Business });
        }