public static ContactsState OnSubmit(ContactsState state)
 {
     return(state with
     {
         Submitting = true
     });
 }
 public static ContactsState OnContactsLoad(ContactsState state)
 {
     return(state with
     {
         Loading = true
     });
 }
 public static ContactsState OnContactsInitialized(ContactsState state)
 {
     return(state with
     {
         Initialized = true
     });
 }
 public static ContactsState OnUpdateFailure(ContactsState state, ContactUpdateFailureAction action)
 {
     return(state with
     {
         Submitting = false,
         ErrorMessage = action.ErrorMessage
     });
 }
 public static ContactsState OnUpdateSuccess(ContactsState state)
 {
     return(state with
     {
         Submitting = false,
         Submitted = true
     });
 }
 public static ContactsState OnStopEditContact(ContactsState state, ContactStopEditAction action)
 {
     return(state with
     {
         CurrentContact = action.Contact,
         ContactButtonText = "Create",
     });
 }
 public static ContactsState OnContactsSet(ContactsState state, ContactsSetAction action)
 {
     return(state with
     {
         Contacts = action.Contacts,
         Loading = false
     });
 }
 public static ContactsState OnEditContact(ContactsState state, ContactEditAction action)
 {
     return(state with
     {
         Submitted = false,
         Submitting = false,
         ShowInputDialog = true,
         CurrentContact = action.Contact,
         ContactButtonText = "Update"
     });
 }
 public static ContactsState OnSaveContact(ContactsState state, ContactsSaveAction action)
 {
     return(state with
     {
         Submitted = false,
         Submitting = true,
         CurrentContact = new CoffeeRoastManagement.Shared.Entities.Contact(),
         ContactButtonText = "Create",
         ShowInputDialog = false,
         ContactEditMode = false
     });
 }
 public static ContactsState OnContactsDelete(ContactsState state, ContactsDeleteAction action)
 {
     if (state.CurrentContact.Id == action.Contact.Id)
     {
         return(state with
         {
             CurrentContact = new CoffeeRoastManagement.Shared.Entities.Contact(),
             ContactButtonText = "Create"
         });
     }
     return(state with
     {
     });
 }
示例#11
0
        private ContactsState GetContactsState(IQueryable <Contact> contacts)
        {
            var state = new ContactsState();

            state.Contacts = contacts.Include(c => c.Address).Select(c => new ContactState {
                Name = c.Name,
                Href = new Link {
                    Rel = "self", Href = GetHref(c.ContactId)
                },
                Address = new AddressState {
                    Address1   = c.Address.Address1,
                    Address2   = c.Address.Address2,
                    City       = c.Address.City,
                    State      = c.Address.State,
                    Country    = c.Address.Country,
                    PostalCode = c.Address.PostalCode
                }
            });
            return(state);
        }
 public static ContactsState OnAddContact(ContactsState state, ContactAddAction action)
 {
     // handle all cases, the last return statement handles the default case
     if (state.ShowInputDialog && state.ContactEditMode)
     {
         // we reset everything
         return(state with
         {
             ShowInputDialog = true,
             ContactEditMode = false,
             CurrentContact = new CoffeeRoastManagement.Shared.Entities.Contact(),
             ContactButtonText = "Create"
         });
     }
     if (state.ShowInputDialog && !state.ContactEditMode)
     {
         if (!string.IsNullOrEmpty(state.CurrentContact.Name) || !string.IsNullOrEmpty(state.CurrentContact.Note) || !string.IsNullOrEmpty(state.CurrentContact.Url))
         {
             return(state with
             {
                 CurrentContact = new CoffeeRoastManagement.Shared.Entities.Contact(),
                 ContactButtonText = "Create",
             });
         }
         else
         {
             return(state with
             {
                 CurrentContact = new CoffeeRoastManagement.Shared.Entities.Contact(),
                 ContactButtonText = "Create",
                 ShowInputDialog = false,
             });
         }
     }
     return(state with
     {
         ShowInputDialog = true,
     });
 }
示例#13
0
 public PluginHelper(ContactsState state)
 {
     this.state = state;
 }
示例#14
0
 public PluginHelper(ContactsState state)
 {
     this.state = state;
 }