Ejemplo n.º 1
0
        private TableAdjustment EditOrCreate(LatticeData <TodoListEntry, TodoListEntry> latticeData)
        {
            var           data         = GetData();
            var           confirmation = latticeData.CommandConfirmation <TodoListEntryCreateEditViewModel>();
            TodoListEntry entry        = null;

            if (confirmation.Id == null)
            {
                entry = new TodoListEntry()
                {
                    Date = DateTime.Now,
                    Icon = confirmation.Icon,
                    Id   = Guid.NewGuid(),
                    Text = confirmation.Text
                };

                data.Add(entry);
                return(latticeData.Adjust(x => x
                                          .UpdateSource(entry)
                                          .Message(LatticeMessage.User("success", "Created", "New ToDo entry created"))));
            }

            entry      = data.FirstOrDefault(c => c.Id == confirmation.Id);
            entry.Date = DateTime.Now;
            entry.Text = confirmation.Text;
            entry.Icon = confirmation.Icon;
            return(latticeData.Adjust(x => x
                                      .UpdateSource(entry)
                                      .Message(LatticeMessage.User("success", "Updated", "ToDo entry updated"))));
        }
Ejemplo n.º 2
0
        public TableAdjustment RemoveRole(LatticeData <Employee, EmployeeRow> latticeData)
        {
            var comandModel = latticeData.CommandConfirmation <TargetRoleCommandViewModel>();
            var subj        = latticeData.CommandSubject();
            var employee    = _context.Employees.FirstOrDefault(x => x.UserId == subj.UserId);

            _userManager.RemoveFromRole(employee.UserId, comandModel.TargetRole);
            return(latticeData.Adjust(x => x
                                      .Message(LatticeMessage.User("success", "Remove", "Role was removed"))
                                      ));
        }
Ejemplo n.º 3
0
        public TableAdjustment Remove(LatticeData <CityAtsAttributes, CityATSAttributesRow> latticeData)
        {
            var confirmationData = latticeData.CommandConfirmation <RemovalConfirmationViewModel>();

            var subj = latticeData.CommandSubject();
            var cityATSAttributes = _context.CityAtsAttributes.FirstOrDefault(x => x.Id == subj.Id);

            _context.CityAtsAttributes.Remove(cityATSAttributes);
            _context.SaveChanges();

            return(latticeData.Adjust(x => x
                                      .Remove(subj)
//                .Message(LatticeMessage.AtsUser("success", "Remove", $"Order removed because of {confirmationData.Cause}"))
                                      ));
        }
Ejemplo n.º 4
0
        public TableAdjustment Remove(LatticeData <Address, AddressRow> latticeData)
        {
            var confirmationData = latticeData.CommandConfirmation <RemovalConfirmationViewModel>();

            var subject = latticeData.CommandSubject();
            var address = _context.Addresses.FirstOrDefault(address1 => address1.Id == subject.Id);

            _context.Addresses.Remove(address);
            _context.SaveChanges();

            return(latticeData.Adjust(wrapper => wrapper
                                      .Remove(subject)
//                .Message(LatticeMessage.AtsUser("success", "Remove", $"Order removed because of {confirmationData.Cause}"))
                                      ));
        }
        public TableAdjustment Remove(LatticeData <PhoneInstallationQueue, PhoneInstallationQueueRow> latticeData)
        {
            var confirmationData = latticeData.CommandConfirmation <RemovalConfirmationViewModel>();

            var subj  = latticeData.CommandSubject();
            var queue = _context.PhoneInstallationQueues.FirstOrDefault(x => x.Id == subj.Id);

            _context.PhoneInstallationQueues.Remove(queue);
            _context.SaveChanges();

            return(latticeData.Adjust(x => x
                                      .Remove(subj)
//                .Message(LatticeMessage.AtsUser("success", "Remove", $"Order removed because of {confirmationData.Cause}"))
                                      ));
        }
Ejemplo n.º 6
0
        public TableAdjustment Remove(LatticeData <PhoneNumber, PhoneNumberRow> latticeData)
        {
            var confirmationData = latticeData.CommandConfirmation <RemovalConfirmationViewModel>();

            var subject     = latticeData.CommandSubject();
            var phoneNumber = _context.PhoneNumbers.FirstOrDefault(number => number.Id == subject.Id);

            _context.PhoneNumbers.Remove(phoneNumber);
            _context.SaveChanges();

            return(latticeData.Adjust(wrapper => wrapper
                                      .Remove(subject)
//                .Message(LatticeMessage.AtsUser("success", "Remove", $"Order removed because of {confirmationData.Cause}"))
                                      ));
        }
Ejemplo n.º 7
0
        public TableAdjustment Remove(LatticeData <UserAccounting, UserAccountingRow> latticeData)
        {
            var confirmationData = latticeData.CommandConfirmation <RemovalConfirmationViewModel>();

            var subj     = latticeData.CommandSubject();
            var userBill = _context.UserAccountings.FirstOrDefault(x => x.Id == subj.Id);

            _context.UserAccountings.Remove(userBill);
            _context.SaveChanges();

            return(latticeData.Adjust(x => x
                                      .Remove(subj)
//                .Message(LatticeMessage.AtsUser("success", "Remove", $"Order removed because of {confirmationData.Cause}"))
                                      ));
        }