コード例 #1
0
        public void Save()
        {
            bool needSave = SortMainId > 0;

            if (string.IsNullOrWhiteSpace(EmployeeId))
            {
                needSave = false;
            }
            if (string.IsNullOrWhiteSpace(ContactType))
            {
                needSave = false;
            }

            if (needSave)
            {
                if (ContactId.HasValue && ContactId.Value > 0)
                {
                    var contact = ContactObject.GetContact(ContactId.Value);
                    if (contact != null)
                    {
                        contact.ContactType = ContactType;
                        if (contact.SetNames(EmployeeId))
                        {
                            contact.Save();
                        }
                    }
                }
                else
                {
                    ContactObject.Add(SortMainId, EmployeeId, ContactType);
                }
            }
        }
コード例 #2
0
        public ActionResult GetContactPartial(int?id)
        {
            if (id.HasValue)
            {
                var contact = ContactObject.GetContact(id.Value);
                if (contact != null)
                {
                    return(PartialView("Partials/ContactsPartial", new ContactModel(contact)));
                }
            }

            return(null);
        }
コード例 #3
0
        public ContactModel(int mainId, int?contactId)
        {
            MainId   = mainId;
            Contacts = ContactObject.GetContacts(mainId);

            if (contactId.HasValue)
            {
                var contact = ContactObject.GetContact(contactId.Value);
                if (contact != null)
                {
                    ContactId         = contact.ContactId;
                    ContactEmployeeId = contact.EmployeeId;
                }
            }
        }
コード例 #4
0
        public JsonResult AddContactToAuthor(int?id)
        {
            string title   = "Error adding Contact as Author";
            string message = "Unable to determain the Contact.";
            bool   isAdded = false;

            if (id.HasValue)
            {
                var contact = ContactObject.GetContact(id.Value);
                if (contact != null && MainObject.CheckUserHasWriteAccess(contact.MainId))
                {
                    isAdded = contact.SaveAsAuthor(ref title, ref message);
                }
            }

            return(Json(new{ title, message, isAdded }));
        }
コード例 #5
0
        public ActionResult RemoveContact(int?id)
        {
            int mid = 0;

            if (id.HasValue)
            {
                var contact = ContactObject.GetContact(id.Value);
                if (contact != null)
                {
                    mid = contact.MainId;
                    if (MainObject.CheckUserHasWriteAccess(mid))
                    {
                        contact.Delete();
                    }
                }
            }

            return(PartialView("Partials/_contactList", ContactObject.GetContacts(mid)));
        }
コード例 #6
0
        public void Save()
        {
            bool needSave = MainId > 0 && !string.IsNullOrWhiteSpace(ContactEmployeeId);

            if (needSave)
            {
                if (ContactId.HasValue && ContactId.Value > 0)
                {
                    var contact = ContactObject.GetContact(ContactId.Value);
                    if (contact != null)
                    {
                        if (contact.SetNames(ContactEmployeeId))
                        {
                            contact.Save();
                        }
                    }
                }
                else
                {
                    ContactObject.Add(MainId, ContactEmployeeId);
                }
            }
        }