public bool AddUserContact(Contact contactToEdit, out Contact contactReturned)
 {
     _vm = DataContext as EditAgriUserContactViewModel;
     _vm.Setup(contactToEdit);
     ShowDialog();
     contactReturned = _vm.Contact;
     return DialogResult != null && (bool) DialogResult;
 }
예제 #2
0
      public   ContactViewModel Map(Contact cont)
        {
            //if (cont == null)
            //    return null;
            //else
            //{
                var contTypes = _contactTypeRepository.GetAll().ToDictionary(n=>n.Id,n=>n.Name);
                var contOwner = _contactRepository.GetAll().OrderBy(n => n.ContactOwnerType).Distinct().ToDictionary(n=>n.Id,n=>n.ContactOwnerType);
                Dictionary<int, string> cl = EnumHelper.EnumToList<ContactClassification>()
                               .ToDictionary(n => (int)n, n => n.ToString());
                ContactViewModel contactVM = new ContactViewModel();
               
                    contactVM.Id = cont.Id;
                    contactVM.BusinessPhone = cont.BusinessPhone;
                    contactVM.Firstname = cont.Firstname;
                    contactVM.Lastname = cont.Lastname;
                    contactVM.Fax = cont.Fax;
                    contactVM.MobilePhone = cont.MobilePhone;
                    contactVM.PostalAddress = cont.PostalAddress;
                    contactVM.PhysicalAddress = cont.PhysicalAddress;
                    contactVM.Email = cont.Email;
                    contactVM.HomePhone = cont.HomePhone ;
                    contactVM.City = cont.City;
                    contactVM.CostCentre = cont.ContactOwnerMasterId;
                    contactVM.HomeTown = cont.HomeTown;
                    contactVM.IsActive = cont._Status == EntityStatus.Active ? true : false;
                    contactVM.JobTitle = cont.JobTitle;
                    contactVM.ChildrenNames = cont.ChildrenNames;
                     contactVM.Company=cont.Company;
                     contactVM.WorkExtPhone=cont.WorkExtPhone;
                     contactVM.SpouseName = cont.SpouseName;
                     contactVM.ContactOwner = (int)cont.ContactOwnerType;
                     contactVM.ContactOwnerList = new SelectList(contOwner, "Key", "Value", (int)cont.ContactOwnerType);
                     contactVM.ContactTypeList = new SelectList(contTypes, "Key", "Value", cont.ContactType == null ? Guid.Empty : cont.ContactType.Id);
                     contactVM.Fullnames = cont.Firstname + " " + cont.Lastname;
                     if (cont.DateOfBirth.HasValue)
                         contactVM.DateofBirth = cont.DateOfBirth.Value;
                if (cont.MStatus != null)
                {
                    contactVM.MaritalStatus = cont.MStatus.ToString();
                    // contactVM.MaritalStatusId = _maritalStatusRepository.GetById(cont.MStatus.Id).Id;
                    //contactVM.MaritalStatus = _maritalStatusRepository.GetById(cont.MStatus.Id).MStatus;
                }

                if (cont.ContactType != null)
                {
                    contactVM.ContactTypeId = _contactTypeRepository.GetById(cont.ContactType.Id).Id;
                    contactVM.ContactTypeName = _contactTypeRepository.GetById(cont.ContactType.Id).Name;
                }
                    contactVM.ClassificationList=new SelectList(cl,"Key","Value");
                    return contactVM;
            //}
        }
예제 #3
0
 public ContactDTO Map(Contact contact)
 {
     if (contact == null) return null;
     return Mapper.Map<Contact, ContactDTO>(contact);
 }
        private ContactItem Map(Contact contact)
        {
            var item = new ContactItem
                {

                    MasterId = contact.Id,
                    Firstname = contact.Firstname,
                    BusinessPhone = contact.BusinessPhone,
                    Fax = contact.Fax,
                    PhysicalAddress = contact.PhysicalAddress,
                    PostalAddress = contact.PostalAddress,
                    HomePhone = contact.HomePhone,
                    MobilePhone = contact.MobilePhone,
                    Email = contact.Email,
                    IsNew = true,
                    ContactOwnerMasterId = contact.ContactOwnerMasterId,


                };
            return item;
        }
        private async void Save()
        {
            DateTime now = DateTime.Now;
            CommoditySupplier.CommoditySupplierType = CommoditySupplierType.Individual;
            CommoditySupplier.JoinDate = now;
            CommoditySupplier.Contact.Clear();
            CommoditySupplier.Name = CommodityOwner.FullName;
            CommoditySupplier.BankId =SelectedBank!=null? SelectedBank.Id:Guid.Empty;
            CommoditySupplier.BankBranchId = SelectedBankBranch != null ? SelectedBankBranch.Id : Guid.Empty;
            CommoditySupplier.AccountNo = AccountNumber;
            CommoditySupplier.AccountName = AccountName;
            

            if (!IsValid(CommoditySupplier))
                return;

            CommodityOwner.CommodityOwnerType = SelectedCommodityOwnerType;
            CommodityOwner.MaritalStatus = SelectedMaritalStatus;
            CommodityOwner.DateOfBirth = DateOfBirth;
            if (DateOfBirth.Year < 18)
            {
                MessageBox.Show("Farmer must be over 18 years old.", "Agrimanagr: Farmer Management",
                                MessageBoxButton.OK);
                return;
            }
           
            CommodityOwner._SetStatus(EntityStatus.Active);

            if (!IsValid() || !IsValid(CommodityOwner)) return;

            CommodityProducer.CommodityProducerCentres.Clear();
            CommodityProducer.CommodityProducerCentres.AddRange(AssignedCentresList.Select(n => n.Centre));
            if (!IsValid() || !IsValid(CommodityProducer)) return;

            using (var c = NestedContainer)
            {
                string responseMsg = "";
                _proxy = Using<IDistributorServiceProxy>(c);
                ResponseBool response = await _proxy.CommoditySupplierAddAsync(CommoditySupplier);
                responseMsg += response.ErrorInfo + "\n";

                string log = string.Format("Created commodity supplier: {0}; Code: {1}; And Type {2}",
                                           CommoditySupplier.Name,
                                           CommoditySupplier.CostCentreCode, CommoditySupplier.CommoditySupplierType);
                Using<IAuditLogWFManager>(c).AuditLogEntry("Manage Commodity Suppliers", log);


                if (response.Success)
                {ContactsList.Clear();
                    var coResponse = await SaveCommodityOwner();
                    if (coResponse.ErrorInfo != "") responseMsg += coResponse.ErrorInfo + "\n";

                    var cpResponse = await SaveCommodityProducer();
                    if (cpResponse.ErrorInfo != "") responseMsg += cpResponse.ErrorInfo + "\n";
                    var enve = new VMContactItem();
                    var contact = new Contact(Guid.NewGuid());
                    contact.BusinessPhone = CommodityOwner.BusinessNumber;
                    contact.ContactClassification=ContactClassification.PrimaryContact;
                    contact.ContactOwnerMasterId = CommoditySupplier.Id;
                    contact.DateOfBirth = CommodityOwner.DateOfBirth;
                    contact.Email = CommodityOwner.Email;
                    contact.Fax = CommodityOwner.FaxNumber;
                    contact.Firstname = CommodityOwner.FirstName;
                    contact.HomePhone = CommodityOwner.PhoneNumber;
                    contact.JobTitle = "Farmer";
                    contact.Lastname = CommodityOwner.LastName;
                    contact.MStatus =CommodityOwner.MaritalStatus;
                    contact.PhysicalAddress = CommodityOwner.PhysicalAddress;
                    contact.PostalAddress = CommodityOwner.PostalAddress;
                    contact.MobilePhone = CommodityOwner.PhoneNumber;
                    contact.ContactType = SelectedContactOwnerType;
                    
                    enve.IsDirty = true;
                    enve.IsNew = true;
                    enve.Contact = contact;
                    ContactsList.Add(enve);

                    bool success = await SaveContacts(CommoditySupplier);

                    if (!coResponse.Success || !cpResponse.Success || !success)
                        response.Success = false;
                }

                MessageBox.Show(responseMsg, "Agrimanagr: Manage Farmer", MessageBoxButton.OK,
                                MessageBoxImage.Information);

                if (response.Success)
                    SendNavigationRequestMessage(
                        new Uri("views/admin/commodityowners/listcommodityowners.xaml", UriKind.Relative));
            }
        }
        private VMContactItem AddContactToList(Guid entityId, Contact contact)
        {
            VMContactItem contactItem = new VMContactItem();
            if (contact.Id == Guid.Empty)
            {
                contact.Id = Guid.NewGuid();
                contactItem.IsNew = true;
                contact.ContactOwnerType = ContactOwnerType.User;
            }

            if (contact.ContactClassification == ContactClassification.PrimaryContact)
            {
                foreach (var cont in ContactsList.Where(n => n.IsPrimaryContact))
                {
                    cont.Contact.ContactClassification = ContactClassification.SecondaryContact;
                    cont.IsDirty = true;
                }
            }

            var existing = ContactsList.FirstOrDefault(n => n.Contact.Id == contact.Id);
            if (existing != null)
                ContactsList.Remove(existing);

            contact.ContactOwnerMasterId = entityId;
            contactItem.Contact = contact;
            contactItem.IsDirty = true;

            ContactsList.Add(contactItem);
            return contactItem;
        }
        private async Task<ResponseBool> SaveSupplierContact(Contact contact)
        {
             var contactItems = new List<ContactItem>();
            var contactItem = new ContactItem();
            string responseMsg = string.Empty;
            var response = new ResponseBool { Success = false };


            using(var c=NestedContainer)
            {
              
                contactItem.MasterId =contact.Id;
                contactItem.Firstname = contact.Firstname;
                contactItem.BusinessPhone = contact.BusinessPhone;
                contactItem.ContactOwnerMasterId =contact.ContactOwnerMasterId;
                contactItem.MobilePhone = contact.MobilePhone;
                contactItem.ContactOwnerType = contact.ContactOwnerType;
                contactItem.Email = contact.Email;
                contactItem.PostalAddress = contact.PostalAddress;
                contactItem.PhysicalAddress = contact.PhysicalAddress;
                contactItem.IsNew = true;
            }
            
            contactItems.Add(contactItem);

           using(var c=NestedContainer)
           {
               response = await Using<IDistributorServiceProxy>(c).ContactsAddAsync(contactItems.ToList());
               return response;
           }
        }
        public HttpResponseMessage ContactsAdd(List<ContactItem> contacts)
        {
            var response = new ResponseBool { Success = false };
            try
            {
                foreach (var contactItem in contacts)
                {
                    if (contactItem.IsNew)
                    {
                        Contact contact = new Contact(contactItem.MasterId)
                        {
                            BusinessPhone = contactItem.BusinessPhone,
                            ChildrenNames = contactItem.ChildrenNames,
                            City = contactItem.City,
                            Company = contactItem.Company,
                            ContactClassification = (ContactClassification)contactItem.ContactClassification,
                            ContactOwnerType = (ContactOwnerType)contactItem.ContactOwnerType,
                            ContactOwnerMasterId = contactItem.ContactOwnerMasterId,
                            DateOfBirth = contactItem.DateOfBirth,
                            Email = contactItem.Email,
                            Fax = contactItem.Fax,
                            Firstname = contactItem.Firstname,
                            HomePhone = contactItem.HomePhone,
                            HomeTown = contactItem.HomeTown,
                            JobTitle = contactItem.JobTitle,
                            Lastname = contactItem.Lastname,
                            MobilePhone = contactItem.MobilePhone,
                            PhysicalAddress = contactItem.PhysicalAddress,
                            PostalAddress = contactItem.PostalAddress,
                            SpouseName = contactItem.SpouseName,
                            WorkExtPhone = contactItem.WorkExtPhone, 
                            MStatus = (MaritalStatas) contactItem.MaritalStatusMasterId,
                        };
                        if (contactItem.ContactTypeMasterId != Guid.Empty)
                            contact.ContactType = _contactTypeRepository.GetById(contactItem.ContactTypeMasterId);

                        _contactRepository.Save(contact);
                    }
                    else
                    {
                        _ContactUpdate(contactItem);
                    }
                }
                response.Success = true;
                response.ErrorInfo = "Successfully saved contacts.";
            }
            catch (DomainValidationException dve)
            {
                string errorMsg = dve.ValidationResults.Results.Aggregate("Error: Invalid contact fields.\n",
                                                                          (current, msg) =>
                                                                          current + ("\t- " + msg.ErrorMessage + "\n"));
                response.ErrorInfo = errorMsg;
                _log.Error(errorMsg, dve);
            }
            catch (Exception ex) //any other
            {
                response.ErrorInfo = "Error: An error occurred when saving the contact information.\nCause: "+ex.Message;
                _log.Error("Error: An error occurred when saving the contact information.", ex);
            }
            return Request.CreateResponse(HttpStatusCode.OK, response);

        }
예제 #9
0
        private ReceiptHeaderInfo FormatHeader(Contact contact, string companyName,Distributor distributr )
        {
            if (contact == null)
                return new ReceiptHeaderInfo()
                           {
                               CompanyName =string.IsNullOrEmpty(companyName)?"Company Name":companyName,
                               PinVatNo =
                               string.Format("VAT No.:{0}  PIN No.:{1}",
                                             distributr != null ? distributr.VatRegistrationNo : "",
                                             distributr != null ? distributr.PIN : "")
                           };

            var physical=string.IsNullOrEmpty(contact.PhysicalAddress)
                                          ? contact.City
                                          : contact.City + " ,"
                                            + contact.PhysicalAddress;
            return new ReceiptHeaderInfo()
                       {
                           CompanyName = string.IsNullOrEmpty(companyName)?"Company Name":companyName,
                           WebSite = "Website:_____________",
                           Email =string.Format("Email:{0}",contact.Email),
                           Address = string.Format("P.O Box: {0},{1}", contact.PostalAddress ?? "_ _ _ _", physical),
                           PinVatNo =
                               string.Format("VAT No.:{0}  PIN No.:{1}",
                                             distributr != null ? distributr.VatRegistrationNo : "",
                                             distributr != null ? distributr.PIN : ""),
                           TelNo =
                               string.Format("Fixed No.:{0},Cell.:{1},Fax:{2}", contact.BusinessPhone,
                                             contact.MobilePhone, contact.Fax)

                       };
        }
예제 #10
0
        protected Guid AddContact(Guid cCId, string contactPerson, string telephone, string fax, string mobile, string address1, string address2, string locality, string postalCode, string city, int classification, MaritalStatas maritalStatus, Guid contactType, int contactOwner,string email)
        {

            Contact contact = new Contact(Guid.NewGuid())
            {
                ContactOwnerMasterId = cCId,
                Firstname = contactPerson,
                BusinessPhone = telephone,
                Fax = fax,
                MobilePhone = mobile,
                PhysicalAddress = address1,
                PostalAddress = address2,
                Company = locality,
                Email = email,
                City = city,
                ContactClassification = ContactClassification.PrimaryContact,
                ContactOwnerType = ContactOwnerType.Distributor,
                 MStatus=MaritalStatas.Single,
                 ContactType=_contactTypeRepository.GetById(contactType)
            };
            contact._SetStatus(EntityStatus.Active);
            return _contactRepository.Save(contact);

        }
예제 #11
0
        public void save(ContactViewModel contactViewModel)
        {

            Contact cont = new Contact(contactViewModel.Id);
           // {
                cont.Firstname = contactViewModel.Firstname;
                cont.Lastname = contactViewModel.Lastname;
                cont.BusinessPhone = contactViewModel.BusinessPhone;
                cont.Fax = contactViewModel.Fax;
                cont.MobilePhone = contactViewModel.MobilePhone;
                cont.PhysicalAddress = contactViewModel.PhysicalAddress;
                cont.PostalAddress = contactViewModel.PostalAddress;
                cont.Company = contactViewModel.Company;
                cont.Email = contactViewModel.Email;
                cont.City = contactViewModel.City;
                cont.ContactClassification = contactViewModel.Classification;
                cont.ContactOwnerMasterId = contactViewModel.CostCentre;
                if (contactViewModel.ContactFor == "User")
                {
                    cont.ContactOwnerType = Distributr.Core.Domain.Master.CostCentreEntities.ContactOwnerType.User;
                }
                if (contactViewModel.ContactFor == "Distributor")
                {
                    cont.ContactOwnerType = Distributr.Core.Domain.Master.CostCentreEntities.ContactOwnerType.Distributor;
                }
                if (contactViewModel.ContactFor == "Outlet")
                {
#if(KEMSA)

                    cont.ContactOwnerType = Distributr.Core.Domain.Master.CostCentreEntities.ContactOwnerType.HealthFacility;
#else
                    cont.ContactOwnerType = Distributr.Core.Domain.Master.CostCentreEntities.ContactOwnerType.Outlet;
#endif
                }
                else
                {
                    cont.ContactOwnerType = (ContactOwnerType)contactViewModel.ContactOwner;
                }
            cont.ContactOwnerMasterId = contactViewModel.CostCentre;
                cont.HomePhone = contactViewModel.HomePhone;
                cont.HomeTown = contactViewModel.HomeTown;
                cont.DateOfBirth = contactViewModel.DateofBirth;
            cont.MStatus = contactViewModel.MaritalStatusId;
               cont.ContactType = _contactTypeRepository.GetById(contactViewModel.ContactTypeId);
                cont.SpouseName = contactViewModel.SpouseName;
                cont.WorkExtPhone = contactViewModel.WorkExtPhone;
                cont.ChildrenNames = contactViewModel.ChildrenNames;
                cont.JobTitle = contactViewModel.JobTitle;
            //};
         
               _contactRepository.Save(cont);
           
        }
예제 #12
0
        private async void Save()
        {
            var contactItems = new List<ContactItem>();
            var contactItem = new ContactItem();
            string responseMsg = string.Empty;
            var response = new ResponseBool { Success = false };


            using(var c=NestedContainer)
            {
                var contact = Using<IContactRepository>(c).GetById(Id);
                if(contact==null)
                {
                    Id = Guid.NewGuid();
                   contact=new Contact(Id);
                }
            
            
                contactItem.MasterId =Id;
                contactItem.BusinessPhone = BusinessNumber;
                contactItem.ContactClassification = (int) SelectedContactClassification;
                contactItem.ContactOwnerMasterId = SupplierId;
                contactItem.ContactTypeMasterId = SelectedContactType!=null?SelectedContactType.Id:Guid.Empty;
                contactItem.Email = Email;
                contactItem.Fax = FaxNumber;
                contactItem.Firstname = FirstName;
                contactItem.HomePhone = OfficeNumber;
                contactItem.Lastname = LastName;
                contactItem.MobilePhone = MobileNumber;
                contactItem.PhysicalAddress = PhysicalAddress;
                contactItem.PostalAddress = PostalAddress;
                contactItem.StatusId = (int) EntityStatus.Active;
                contactItem.IsNew = true;
            }
            
            contactItems.Add(contactItem);

           using(var c=NestedContainer)
           {
               response = await Using<IDistributorServiceProxy>(c).ContactsAddAsync(contactItems.ToList());
               MessageBox.Show(response.ErrorInfo, "Agrimanagr: Manage contacts", MessageBoxButton.OK,
                               MessageBoxImage.Information);
           }
           if(response.Success)
               SendNavigationRequestMessage(new Uri("/Views/Admin/SupplierContacts/ListingSupplierContacts.xaml", UriKind.Relative));
        }
 public void Setup(Contact contact)
 {
     Contact = contact.Clone<Contact>();
     LoadContactTypes();
     LoadMaritalStatuses();
     if (Contact.ContactType != null)
     {
         SelectedContactType = ContactTypesList.FirstOrDefault(n => n.Id == Contact.ContactType.Id);
         SelectedMaritalStatus = Contact.MStatus;
     }
 }
        public HttpResponseMessage CommodityOwnerAdd(CommodityOwnerItem commodityOwnerItem)
        {
            var response = new ResponseBool { Success = false };
            try
            {
                var commodityOwner = new CommodityOwner(commodityOwnerItem.MasterId)
                                         {
                                             Surname = commodityOwnerItem.Surname,
                                             _Status = (EntityStatus) commodityOwnerItem.StatusId,
                                             PostalAddress = commodityOwnerItem.PostalAddress,
                                             PinNo = commodityOwnerItem.PinNo,
                                             PhysicalAddress = commodityOwnerItem.PhysicalAddress,
                                             OfficeNumber = commodityOwnerItem.OfficeNumber,
                                             BusinessNumber = commodityOwnerItem.BusinessNumber,
                                             PhoneNumber = commodityOwnerItem.PhoneNumber,
                                             IdNo = commodityOwnerItem.IdNo,
                                             LastName = commodityOwnerItem.LastName,
                                             MaritalStatus = (MaritalStatas) commodityOwnerItem.MaritalStatasMasterId,
                                             Code = commodityOwnerItem.Code,
                                             CommodityOwnerType =
                                                 _commodityOwnerTypeRepository.GetById(
                                                     commodityOwnerItem.CommodityOwnerTypeMasterId),
                                             CommoditySupplier =
                                                 _commoditySupplierRepository.GetById(
                                                     commodityOwnerItem.CommoditySupplierMasterId) as CommoditySupplier,
                                             DateOfBirth = commodityOwnerItem.DateOfBirth,
                                             Description = commodityOwnerItem.Description,
                                             Email = commodityOwnerItem.Email,
                                             FaxNumber = commodityOwnerItem.FaxNumber,
                                             FirstName = commodityOwnerItem.FirstName,
                                             Gender = (Gender) commodityOwnerItem.GenderId,
                                         };
                _commodityOwnerRepository.Save(commodityOwner);
                var contact = _contactRepository.GetByContactsOwnerId(commodityOwnerItem.CommoditySupplierMasterId).FirstOrDefault();
                if(contact==null)
                {
                    contact = new Contact(Guid.NewGuid());
                }
                contact.BusinessPhone = commodityOwnerItem.BusinessNumber;
                    contact.ChildrenNames = "";
                    contact.City = "";
                    contact.Company = "";
                    contact.ContactClassification=ContactClassification.PrimaryContact;
                    contact.ContactOwnerMasterId = commodityOwnerItem.CommoditySupplierMasterId;
                    contact.ContactOwnerType=ContactOwnerType.CommoditySupplier;
                    contact.ContactType = _contactTypeRepository.GetById(
                        commodityOwnerItem.CommodityOwnerTypeMasterId);
                    contact.DateOfBirth = commodityOwnerItem.DateOfBirth;
                    contact.Email = commodityOwnerItem.Email;
                    contact.Fax = commodityOwnerItem.FaxNumber;
                    contact.Firstname = commodityOwnerItem.FirstName;
                    contact.HomePhone = commodityOwnerItem.BusinessNumber;
                    contact.HomeTown = "";
                    contact.JobTitle = "Farmer";
                    contact.Lastname = commodityOwnerItem.LastName;
                    contact.MobilePhone = commodityOwnerItem.PhoneNumber;
                    contact.BusinessPhone = commodityOwnerItem.BusinessNumber;
                    contact.PhysicalAddress = "";
                    contact.PostalAddress = commodityOwnerItem.PhysicalAddress;
                    contact.SpouseName = "";
                _contactRepository.Save(contact);

                response.Success = true;
                response.ErrorInfo = "Commodity producer successfully added.";
            }
            catch (DomainValidationException dve)
            {
                string errorMsg = dve.ValidationResults.Results.Aggregate("Error: Invalid commodity owner fields.\n",
                                                                          (current, msg) =>
                                                                          current + ("\t- " + msg.ErrorMessage + "\n"));
                response.ErrorInfo = errorMsg;
                _log.Error(errorMsg, dve);
            }
            catch (Exception ex) //any other
            {
                response.ErrorInfo = "Error: An error occurred when saving the entity.\n" + ex.ToString();
                _log.Error("Error: An error occurred when saving the entity.", ex);
            }
            return Request.CreateResponse(HttpStatusCode.OK, response);
        }
예제 #15
0
        private Contact GetContactEntity(MasterBaseDTO masterBase)
        {
            ContactDTO dto = masterBase as ContactDTO;
            Contact entity = new Contact(masterBase.MasterId);
            entity.BusinessPhone = dto.BusinessPhone;
            entity.ChildrenNames = dto.ChildrenNames;
            entity.City = dto.City;
            entity.Company = dto.Company;
            entity.ContactClassification = (ContactClassification)dto.ContactClassificationId;
            entity.ContactOwnerMasterId = dto.ContactOwnerMasterId;
            entity.ContactOwnerType = (ContactOwnerType)dto.ContactOwnerType;
            if (dto.ContactTypeMasterId != Guid.Empty)
                entity.ContactType = _contactTypeRepository.GetById(dto.ContactTypeMasterId);
            entity.DateOfBirth = dto.DateOfBirth;
            entity.Email = dto.Email;
            entity.Fax = dto.Fax;
            entity.Firstname = dto.Firstname;
            entity.HomePhone = dto.HomePhone;
            entity.HomeTown = dto.HomeTown;
            entity.JobTitle = dto.JobTitle;
            entity.Lastname = dto.Lastname;
            entity.MobilePhone = dto.MobilePhone;
            //if(dto.MaritalStatusMasterId!=Guid.Empty)
            //    entity.MStatus = _maritalStatusRepository.GetById(dto.MaritalStatusMasterId);
            entity.PhysicalAddress = dto.PhysicalAddress;
            entity.PostalAddress = dto.PostalAddress;
            entity.SpouseName = dto.SpouseName;
            entity.WorkExtPhone = dto.WorkExtPhone;
            return entity;

        }
예제 #16
0
 private NewListContactViewModel Map(Contact item)
 {
     var contact = new NewListContactViewModel();
     contact.Name = item.Firstname;
     contact.RowNumber = 0;
     contact.MaritalStats = item.MStatus;
     if (item.DateOfBirth != null) contact.DoB = (DateTime)item.DateOfBirth;
     contact.JobTitle = item.JobTitle;
     contact.Company = item.Company;
     contact.Address = item.PostalAddress;
     contact.BusinessPhone = item.BusinessPhone;
     contact.MobilePhone = item.MobilePhone;
     contact.Email = item.Email;
     contact.ContactClassification = item.ContactClassification;
     contact.Id = item.Id;
     return contact;
 }
예제 #17
0
        private async void Save()
        {
              var commodityOwner =new CommodityOwner(CommodityOwnerId);
              var commoditySupplier=new CommoditySupplier(Id);
              var  commodityProducer = new CommodityProducer(CommodityProducerId);
              var contact = new Contact(ContactId);

         using (var c = NestedContainer)
            {
                commodityOwner.Code = OwnerCode;
                if (string.IsNullOrEmpty(commodityOwner.Code))
                {
                    MessageBox.Show("Farmer Code is a Required Field", "Agrimanagr: Farmer Management",
                                        MessageBoxButton.OK);
                    return;

                }
                commodityOwner.Surname = Surname;
                commodityOwner.FirstName = FirstName;
                commodityOwner.LastName = MiddleName;
                commodityOwner.IdNo = IdNumber;
                commodityOwner.PinNo = PinNumber;
                //CommodityOwner.Gender =;
                commodityOwner.PhysicalAddress = PhysicalAddress;
                commodityOwner.PostalAddress = PostalAddress;
                commodityOwner.Email = Email;
                commodityOwner.PhoneNumber = PhoneNumber;
                commodityOwner.BusinessNumber = BusinessNumber;
                commodityOwner.FaxNumber = FaxNumber;
                commodityOwner.OfficeNumber = OfficeNumber;
                commodityOwner.Description = Description;
                commodityOwner.DateOfBirth = DateOfBirth;
                commodityOwner.CommoditySupplier = commoditySupplier;
                commodityOwner._Status = EntityStatus.Active;
                if (DateTime.Now.Year - DateOfBirth.Year < 18)
                    {
                        MessageBox.Show("Farmer must be over 18 years old.", "Agrimanagr: Farmer Management",
                                        MessageBoxButton.OK);
                        return;
                    }
            
                commodityOwner.MaritalStatus = SelectedMaritalStatus;
                commodityOwner.CommodityOwnerType = SelectedCommodityOwnerType;

                commoditySupplier.JoinDate = DateTime.Now.Date;
                commoditySupplier.AccountName = AccountName;
                commoditySupplier.AccountNo = AccountNumber;

                commoditySupplier._Status = EntityStatus.Active;
                commoditySupplier.PinNo = PinNumber;
                commoditySupplier.BankId = SelectedBank.Id;
                commoditySupplier.BankBranchId = SelectedBankBranch.Id;
                commoditySupplier.CommoditySupplierType = SelectedCommoditySupplierType;
                commoditySupplier.CostCentreCode = CostCenterCode;
                commoditySupplier.Name = AccountFullName;
                    var config = Using<IConfigService>(c).Load();
                    commoditySupplier.ParentCostCentre = new CostCentreRef {Id = config.CostCentreId};

                if (!IsValid(commoditySupplier))
                    return;

                commodityProducer.CommoditySupplier = commoditySupplier;
                commodityProducer._SetStatus(EntityStatus.Active);
                commodityOwner.BusinessNumber = BusinessNumber;
               if (!IsValid(commodityOwner)) return;

                commodityProducer.CommodityProducerCentres.Clear();
             
             
                commodityProducer.CommodityProducerCentres.AddRange(AssignedCentresList.Select(n => n.Centre));
                commodityProducer.Code = FarmCode;
                if (string.IsNullOrEmpty(commodityProducer.Code))
                {
                    MessageBox.Show("Farm Code is a Required Field", "Agrimanagr: Farmer Management",
                                        MessageBoxButton.OK);
                    return;
                }
                commodityProducer.Acrage = Acerage;
                commodityProducer.Name = FarmName;
                commodityProducer._Status = EntityStatus.Active;
                commodityProducer.RegNo = FarmRegistrationNo;
                commodityProducer.PhysicalAddress = FarmPhysicalAddress;
                commodityProducer.Description = FarmDescription;
                commodityProducer.CommoditySupplier = commoditySupplier;


                contact.BusinessPhone = BusinessNumber;
                contact.Email = Email;
                contact.ContactOwnerMasterId = commoditySupplier.Id;
                contact.Firstname = AccountFullName;
                contact.PostalAddress = PostalAddress;
                contact.MobilePhone = PhoneNumber;
                contact.PhysicalAddress = PhysicalAddress;
                contact.ContactOwnerType=ContactOwnerType.CommoditySupplier;

                if (!IsValid() || !IsValid(commodityProducer)) return;


                   string responseMsg = "";
                   _proxy = Using<IDistributorServiceProxy>(c);
                   var mapper = Using<IMasterDataToDTOMapping>(c);
                    var commoditySupplierdto = mapper.Map(commoditySupplier);
                    ResponseBool response = await _proxy.CommoditySupplierAddAsync(commoditySupplierdto);
                    responseMsg += response.ErrorInfo + "\n";

                    string log = string.Format("Created commodity supplier: {0}; Code: {1}; And Type {2}",
                                               commoditySupplier.Name,
                                               commoditySupplier.CostCentreCode, commoditySupplier.CommoditySupplierType);
                    Using<IAuditLogWFManager>(c).AuditLogEntry("Manage Commodity Suppliers", log);


                    if (response.Success)
                    {
                        ContactsList.Clear();
                        var coResponse = await SaveCommodityOwner(commodityOwner);
                        if (coResponse.ErrorInfo != "") responseMsg += coResponse.ErrorInfo + "\n";

                        var contactResponse = await SaveSupplierContact(contact);
                        if (contactResponse.ErrorInfo != "") responseMsg += contactResponse.ErrorInfo + "\n";

                        var cpResponse = await SaveCommodityProducer(commodityProducer);
                        if (cpResponse.ErrorInfo != "") responseMsg += cpResponse.ErrorInfo + "\n";

                       

                        if (!coResponse.Success || !cpResponse.Success)
                            response.Success = false;
                    }
                    if (response.Success)
                    {
                          responseMsg = "Farmer Successfully Added ";
                        MessageBox.Show(responseMsg, "Agrimanagr: Manage Farmer", MessageBoxButton.OK,
                                    MessageBoxImage.Information);

                         SendNavigationRequestMessage(
                            new Uri("views/admin/Supplier/ListOfSuppliers.xaml", UriKind.Relative));
                    }
                    else
                    {
                        MessageBox.Show(responseMsg, "Agrimanagr: Manage Farmer", MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                    }

            
                       
            }
        }
        private void AddContactToList(MasterEntity entity, Contact contact)
        {
            VMContactItem contactItem = new VMContactItem {IsNew = contact._Status == EntityStatus.New, IsDirty = true};
            if (contact.Id == Guid.Empty)
            {
                contact.Id = Guid.NewGuid();
                contact.ContactOwnerType = ContactOwnerType.User;
                if (contact.ContactClassification == ContactClassification.None)
                    contact.ContactClassification = ContactClassification.SecondaryContact;

                if(ContactsList.All(n => n.Contact.ContactClassification != ContactClassification.PrimaryContact))
                    contact.ContactClassification = ContactClassification.PrimaryContact;
            }

            if (contact.ContactClassification == ContactClassification.PrimaryContact)
            {
                foreach (var cont in ContactsList.Where(n => n.IsPrimaryContact))
                {
                    cont.Contact.ContactClassification = ContactClassification.SecondaryContact;
                    cont.IsDirty = true;
                }
            }

            var existing = ContactsList.FirstOrDefault(n => n.Contact.Id == contact.Id);
            if (existing != null)
                ContactsList.Remove(existing);

            contact.ContactOwnerMasterId = entity.Id;
            contactItem.Contact = contact;

            ContactsList.Add(contactItem);
        }
예제 #19
0
 private void AssertContact(Contact competitor, Contact savedCompetitor)
 {
     Assert.AreEqual(competitor.Firstname,savedCompetitor.Firstname);
     Assert.AreEqual(competitor.BusinessPhone,savedCompetitor.BusinessPhone);
     Assert.AreEqual(competitor.Fax,savedCompetitor.Fax);
     Assert.AreEqual(competitor.MobilePhone,savedCompetitor.MobilePhone);
     Assert.AreEqual(competitor.MStatus,savedCompetitor.MStatus);
     Assert.AreEqual(competitor.ContactType.Code,savedCompetitor.ContactType.Code);
     Assert.AreEqual(competitor.PhysicalAddress, savedCompetitor.PhysicalAddress);
     Assert.AreEqual(competitor.ContactOwnerType, savedCompetitor.ContactOwnerType);
     Assert.AreEqual(competitor._Status, EntityStatus.Active);
 }