Пример #1
0
     void LoadForContactEdit()
      {
          using (StructureMap.IContainer c = NestedContainer)
          {
              PageTitle = GetLocalText("sl.contacts.edit.title.edit"); // "Edit Contact";


              var contact = Using<IContactRepository>(c).GetById(Id);
              FirstName = contact.Firstname;
              LastName = contact.Lastname;
              DateOfBirth = contact.DateOfBirth == null ? DateTime.Now : (DateTime)contact.DateOfBirth;
              SpouseName = contact.SpouseName;
              Company = contact.Company;
              JobTitle = contact.JobTitle;
              MobilePhone = contact.MobilePhone;
              BusinessPhone = contact.BusinessPhone;
              HomePhone = contact.HomePhone;
              WorkExtensionPhone = contact.WorkExtPhone;
              Email = contact.Email;
              Fax = contact.Fax;
              PhysicalAddress = contact.PhysicalAddress;
              HomeTown = contact.HomeTown;
              City = contact.City;
              ChildrenNames = contact.ChildrenNames;
              SelectedMaritalStatus = contact.MStatus;

              try
              {
                  SelectedContactOwnerType = ContactOwnerTypes.First(n => n == contact.ContactOwnerType);
              }
              catch
              {
                  SelectedContactOwnerType = ContactOwnerTypes.FirstOrDefault();
              }
             
              if (contact.ContactOwnerMasterId != Guid.Empty)
              {
                  var costcentre = Using<ICostCentreRepository>(c).GetById(contact.ContactOwnerMasterId);
                  if(costcentre !=null)
                  SelectedContactOwner = new ContactOwnerLookUp() {Id =costcentre.Id,Name = costcentre.Name};
                  ContactOwners.Add(SelectedContactOwner);
                  //costcentre != null ? ContactOwners.FirstOrDefault(n => n.Name == costcentre.Name)
                  // : ContactOwners.FirstOrDefault();
              }
              if (contact.ContactType != null)
                  SelectedContactType = ContactTypes.First(n => n.Id == contact.ContactType.Id);
              if (contact.ContactClassification == ContactClassification.PrimaryContact)
                  
              SelectedContactClassification = contact.ContactClassification != 0
                                                  ? contact.ContactClassification
                                                  : ContactClassification.SecondaryContact;
          }
      }
Пример #2
0
      void ClearViewModel()
      {
          FirstName = "";
          LastName = "";
          DateOfBirth = DateTime.Now;
          SpouseName = "";
          Company = "";
          JobTitle = "";
          MobilePhone = "";
          WorkExtensionPhone = "";
          Email = "";
          Fax = "";
          PhysicalAddress = "";
          PostalAddress = "";
          HomePhone = "";
          BusinessPhone = "";
          City = "";
          ChildrenNames = "";
          HomeTown = "";
          MaritalStatuses.Clear();
          ContactOwnerTypes.Clear();
          ContactOwners.Clear();
          ContactClassifications.Clear();
          ContactTypes.Clear();
         

          SelectedContactOwnerType = ContactOwnerType.None;
         SelectedMaritalStatus = MaritalStatas.Unknown;
         SelectedContactType = new ContactType(Guid.Empty) { Name = "--Select contact Type--" };
         SelectedContactOwner = new ContactOwnerLookUp() { Id =Guid.Empty,Name="--Select Contact owner--" };
          ContactOwnerTypeName = "";


      }
Пример #3
0
      void SetUp()
      {
          ClearViewModel();
          using (var c=NestedContainer)
          {
              CanEdit = Using<IConfigService>(c).ViewModelParameters.CurrentUserRights.CanManageContacts;
              LoadContactOwnerTypes();
              LoadContactClassifications();
              LoadMaritalStatuses();
              LoadContactTypes();
              PageTitle = GetLocalText("sl.contacts.edit.title.new"); //"Create Contact";
              SelectedContactOwner = new ContactOwnerLookUp()
              {
                  Id = Guid.Empty,
                  Name = GetLocalText("sl.contacts.edit.contactOwner.default")
                  /*"--Please Select Contact Owner--"*/
              };
              ContactOwners.Add(SelectedContactOwner);

          }
          SelectedContactOwnerType = ContactOwnerType.Distributor;
          SelectedMaritalStatus=MaritalStatas.Unknown;
         
      }