public ContactDetailsModel(ContactInstance contact)
 {
     FirstName   = contact.FirstName;
     LastName    = contact.LastName;
     CustomerId  = contact.UniqueId;
     LendedBooks = new List <ProductInstance>();
 }
Example #2
0
        public void Update(ContactInstance p)
        {
            var a = p.Contact as Contacts;

            p.FirstName = FirstName;
            p.LastName  = LastName;
        }
Example #3
0
        /// <summary>
        /// Deserializza una struttura JSON di tipo UDSWorkflowModel recuperata da Workflow (property).
        /// </summary>
        /// <returns>oggetto UDSDto</returns>
        public UDSDto ReadUDSWorkflowJson(string udsWorkflowJson, Data.Entity.UDS.UDSRepository repository)
        {
            if (string.IsNullOrEmpty(udsWorkflowJson))
            {
                throw new ArgumentNullException("udsWorkflowJson");
            }

            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            UDSModel         udsModel = UDSModel.LoadXml(repository.ModuleXML);
            UDSWorkflowModel model    = JsonConvert.DeserializeObject <UDSWorkflowModel>(udsWorkflowJson, DocSuiteContext.DefaultWebAPIJsonSerializerSettings);
            UDSModelField    udsField;

            foreach (Section metadata in udsModel.Model.Metadata)
            {
                foreach (FieldBaseType item in metadata.Items)
                {
                    udsField = new UDSModelField(item);
                    foreach (KeyValuePair <string, string> data in model.DynamicDatas)
                    {
                        if (data.Key.Eq(udsField.ColumnName))
                        {
                            udsField.Value = data.Value;
                        }
                    }
                }
            }

            if (udsModel.Model.Contacts != null && model.Contact != null)
            {
                //todo: sarĂ  sempre e solo un singolo contatto?
                Contacts contact = udsModel.Model.Contacts.FirstOrDefault();
                if (model.Contact.HasId())
                {
                    ContactInstance newInstance = new ContactInstance()
                    {
                        IdContact = model.Contact.Id.Value
                    };
                    contact.ContactInstances = (contact.ContactInstances ?? Enumerable.Empty <ContactInstance>()).Concat(new ContactInstance[] { newInstance }).ToArray();
                }
                else if (!string.IsNullOrEmpty(model.Contact.Description))
                {
                    ContactManualInstance newManualInstance = new ContactManualInstance()
                    {
                        ContactDescription = model.Contact.Description
                    };
                    contact.ContactManualInstances = (contact.ContactManualInstances ?? Enumerable.Empty <ContactManualInstance>()).Concat(new ContactManualInstance[] { newManualInstance }).ToArray();
                }
            }

            UDSDto udsDto = new UDSDto()
            {
                UDSModel = udsModel
            };

            return(udsDto);
        }
Example #4
0
        public void UpdateTest()
        {
            var obj = new ContactEditModel(contact);

            TestProperty(() => obj.FirstName, x => obj.FirstName = x, contact.FirstName);
            ContactInstance newInstance = ContactInstance.Random();

            obj.Update(newInstance);
            TestProperty(() => obj.FirstName, x => obj.FirstName = x, newInstance.FirstName);
        }
        public static List <ContactInstance> Load()
        {
            var list = new List <ContactInstance>();

            foreach (var u in db.Contacts)
            {
                var au = new ContactInstance();
                au.UniqueId  = u.Id;
                au.FirstName = u.FirstName;
                au.LastName  = u.LastName;
                list.Add(au);
            }
            return(list);
        }
        public static void DeleteContactInstance(ContactInstance instance)
        {
            ContactDal dbContactDal = db.Contacts.Find(instance.UniqueId);

            if (dbContactDal == null)
            {
                Console.WriteLine("Couldn't find entity to delete!");
            }
            else
            {
                db.Contacts.Remove(entity: dbContactDal);
                db.SaveChanges();
            }
        }
        public ActionResult AddCustomer([Bind(Include = "Id,FirstName,LastName")] ContactEditModel e)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddCustomer", e));
            }
            var contact = new ContactInstance {
                Contact = new Contacts()
            };

            contact.UniqueId = GetRandom.String();
            e.Update(contact);
            BusinessContact.SaveContactInstance(contact);
            return(RedirectToAction("Index"));
        }
Example #8
0
        public static ContactInstance[] GetContactInstances(ICollection <ContactDTO> contacts)
        {
            IList <ContactInstance> contactInstances = new List <ContactInstance>();
            IList <ContactDTO>      addressContacts  = contacts.Where(x => x.Type == ContactDTO.ContactType.Address).ToList();

            foreach (ContactDTO addressContact in addressContacts)
            {
                ContactInstance instance = new ContactInstance {
                    IdContact = addressContact.Contact.Id
                };
                contactInstances.Add(instance);
            }

            return(contactInstances.ToArray());
        }
        public static void UpdateContactInstance(ContactInstance instance)
        {
            ContactDal dbContactDal = db.Contacts.Find(instance.UniqueId);

            if (dbContactDal == null)
            {
                Console.WriteLine("Couldn't find entity to update!");
            }
            else
            {
                dbContactDal.FirstName = instance.FirstName;
                dbContactDal.LastName  = instance.LastName;
                db.Contacts.AddOrUpdate(dbContactDal);
                db.SaveChanges();
            }
        }
Example #10
0
 public ContactViewModel(ContactInstance p)
 {
     Id        = p.UniqueId;
     FirstName = p.FirstName;
     LastName  = p.LastName;
 }
 public static void SaveContactInstance(ContactInstance instance)
 {
     db.Contacts.Add(new ContactDal(instance));
     db.SaveChanges();
 }
 public ContactDal(ContactInstance c)
 {
     Id        = c.UniqueId;
     FirstName = c.FirstName;
     LastName  = c.LastName;
 }
Example #13
0
 public void Initialize()
 {
     contact = ContactInstance.Random();
 }
Example #14
0
 public ContactEditModel(ContactInstance contact)
 {
     Id        = contact.UniqueId;
     FirstName = contact.FirstName;
     LastName  = contact.LastName;
 }
Example #15
0
        private void FillContacts(UDSEntityDto entityDto, UDSModel model)
        {
            if (model.Model.Contacts.IsNullOrEmpty())
            {
                return;
            }

            ICollection <WebAPIDto <UDSContact> > result = WebAPIImpersonatorFacade.ImpersonateFinder(UDSContactFinder,
                                                                                                      (impersonationType, finder) =>
            {
                finder.ResetDecoration();
                finder.IdUDS          = entityDto.Id;
                finder.EnablePaging   = false;
                finder.ExpandRelation = true;
                return(finder.DoSearch());
            });

            if (result == null || !result.Select(s => s.Entity).Any())
            {
                return;
            }

            entityDto.Contacts = result.Select(s => s.Entity).Select(s => new UDSEntityContactDto()
            {
                ContactManual = s.ContactManual,
                ContactType   = (Helpers.UDS.UDSContactType)s.ContactType,
                IdContact     = s.Relation?.EntityId,
                UDSContactId  = s.UniqueId,
                Label         = s.ContactLabel
            }).ToList();

            foreach (Contacts modelContacts in model.Model.Contacts)
            {
                IList <UDSEntityContactDto> contacts = entityDto.Contacts.Where(x => x.Label.Eq(modelContacts.Label)).ToList();
                if (contacts == null || !contacts.Any())
                {
                    continue;
                }

                foreach (UDSEntityContactDto contact in contacts)
                {
                    if (contact.ContactType == Helpers.UDS.UDSContactType.Contact)
                    {
                        if (contact.IdContact.HasValue)
                        {
                            ContactInstance newInstance = new ContactInstance()
                            {
                                IdContact = contact.IdContact.Value
                            };
                            modelContacts.ContactInstances = (modelContacts.ContactInstances ?? Enumerable.Empty <ContactInstance>()).Concat(new ContactInstance[] { newInstance }).ToArray();
                        }
                    }
                    else
                    {
                        ContactManualInstance newManualInstance = new ContactManualInstance()
                        {
                            ContactDescription = contact.ContactManual
                        };
                        modelContacts.ContactManualInstances = (modelContacts.ContactManualInstances ?? Enumerable.Empty <ContactManualInstance>()).Concat(new ContactManualInstance[] { newManualInstance }).ToArray();
                    }
                }
            }
        }