Exemple #1
0
        public static ContactEditVM GetVM(Contact contact)
        {
            var vm = new ContactEditVM();

            if (contact != null)
            {
                vm.FacebookLink = contact.FacebookLink;
                vm.InstagramLink = contact.InstagramLink;
                vm.TwitterLink = contact.TwitterLink;
                vm.EMail = contact.EMail;
            }

            return vm;
        }
Exemple #2
0
        public static void GetContact(ContactEditVM vm, ref Contact contact)
        {
            if (contact == null)
            {
                contact = new Contact();
            }

            if (vm != null)
            {
                contact.FacebookLink = vm.FacebookLink;
                contact.InstagramLink = vm.InstagramLink;
                contact.TwitterLink = vm.TwitterLink;
                contact.EMail = vm.EMail;
            }
        }
        public virtual ActionResult Edit(ContactEditVM vm)
        {
            if (!ModelState.IsValid)
            {
                return Json(new { success = false });
            }
            try
            {
                var contact = unitOfWork.ContactRepository.Get().FirstOrDefault();
                if (contact == null)
                    contact = unitOfWork.ContactRepository.Insert(new Contact() { ContactId = Guid.NewGuid() });
                ContactMapper.GetContact(vm, ref contact);
                
                unitOfWork.Save();

                return Json(new { success = true });
            }
            catch
            {
                return Json(new { success = false });
            }
        }