示例#1
0
        public void Update(NameOrDescription name, long?updatedByUser)
        {
            Name = name;
            Audit.Update(updatedByUser);

            Validate();
        }
示例#2
0
        public async Task <ICommandResult> Handle(CreateAccountCommand command)
        {
            NameOrDescription      name = new NameOrDescription(command.Name);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(command.CompanyId, command.BranchOfficeId);
            Account account = new Account(name, command.CreatedByUserId, companyAndBranchOffice, command.MachineNameOrIP);

            AddNotifications(name.Notifications);
            AddNotifications(account.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _accountRepository.Create(account);

            return(new CommandResult(
                       true,
                       Messages.RECORDED_WITH_SUCCESS,
                       new AccountCommandResult
            {
                Id = account.Id,
                Name = account.Name.Name,
                CreatedDate = account.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = account.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = account.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = account.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = account.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = account.Audit.CompanyAndBranchOffice.BranchOfficeId
            }));
        }
示例#3
0
        public User(NameOrDescription name,
                    string login,
                    string password,
                    string confirmPassword,
                    long nivel,
                    decimal percentM,
                    decimal percentB,
                    long createdByUser,
                    CompanyAndBranchOffice companyAndBranchOfficeId,
                    string machineNameOrIP)
        {
            Name             = name;
            Login            = login;
            Password         = Encrypt(password);
            _confirmPassword = Encrypt(confirmPassword);
            Active           = EActiveDeactive.Active;
            Nivel            = nivel;
            PercentM         = percentM;
            PercentB         = percentB;

            CreatedDateBy          created = new CreatedDateBy(createdByUser);
            UpdatedDateBy          updated = new UpdatedDateBy(null);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(companyAndBranchOfficeId.CompanyId, companyAndBranchOfficeId.BranchOfficeId);
            Audit audit = new Audit(created, updated, companyAndBranchOffice, ERecordStatus.Active, machineNameOrIP);

            Audit = audit;

            Validate();
        }
示例#4
0
        public async Task <ICommandResult> Handle(CreateCallGroupCommand command)
        {
            NameOrDescription      name = new NameOrDescription(command.Name);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(command.CompanyId, command.BranchOfficeId);
            CallGroup callGroup = new CallGroup(name, command.CreatedByUserId, companyAndBranchOffice, command.MachineNameOrIP);

            AddNotifications(name.Notifications);
            AddNotifications(callGroup.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _CallGroupRepository.Create(callGroup);

            return(new CommandResult(
                       true,
                       Messages.RECORDED_WITH_SUCCESS,
                       new CallGroupCommandResult
            {
                Id = callGroup.Id,
                Name = callGroup.Name.Name,
                CreatedDate = callGroup.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = callGroup.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = callGroup.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = callGroup.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = callGroup.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = callGroup.Audit.CompanyAndBranchOffice.BranchOfficeId,
                MachineNameOrIP = callGroup.Audit.MachineNameOrIP,
            }));
        }
示例#5
0
        public Call(long callTypeId,
                    long callGroupId,
                    long sectorId,
                    long agreementId,
                    long customerId,
                    long employeeId,
                    EPriority priority,
                    NameOrDescription title,
                    string details,
                    long createdByUser,
                    CompanyAndBranchOffice companyId,
                    string machineNameOrIP)
        {
            CallTypeId  = callTypeId;
            CallGroupId = callGroupId;
            SectorId    = sectorId;
            ContractId  = agreementId;
            CustomerId  = customerId;
            EmployeeId  = employeeId;
            Priority    = priority;
            Title       = title;
            Details     = details;
            Status      = 0;

            CreatedDateBy          created = new CreatedDateBy(createdByUser);
            UpdatedDateBy          updated = new UpdatedDateBy(null);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(companyId.CompanyId, companyId.BranchOfficeId);
            Audit audit = new Audit(created, updated, companyAndBranchOffice, ERecordStatus.Active, machineNameOrIP);

            Audit = audit;

            Validate();
        }
示例#6
0
        public async Task <ICommandResult> Handle(CreateCallCommand command)
        {
            NameOrDescription      title = new NameOrDescription(command.Title);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(command.CompanyId, command.BranchOfficeId);
            Call call = new Call(
                command.CallTypeId,
                command.CallGroupId,
                command.CustomerId,
                command.SectorId,
                command.ContractId,
                command.EmployeeId,
                command.Priority,
                title,
                command.Details,
                command.CreatedByUserId,
                companyAndBranchOffice,
                command.MachineNameOrIP);

            AddNotifications(title.Notifications);
            AddNotifications(call.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _CallRepository.Create(call);

            return(new CommandResult(
                       true,
                       Messages.RECORDED_WITH_SUCCESS,
                       new CallCommandResult
            {
                Id = call.Id,
                CallTypeId = call.CallTypeId,
                CallGroupId = call.CallGroupId,
                CustomerId = call.CustomerId,
                SectorId = call.SectorId,
                ContractId = call.ContractId,
                EmployeeId = call.EmployeeId,
                Priority = call.Priority,
                Title = call.Title.Name,
                Details = call.Details,
                Status = call.Status,
                CreatedDate = call.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = call.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = call.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = call.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = call.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = call.Audit.CompanyAndBranchOffice.BranchOfficeId,
                MachineNameOrIP = call.Audit.MachineNameOrIP
            }));
        }
示例#7
0
        public async Task <ICommandResult> Handle(EditUserCommand command)
        {
            User user = await _UserRepository.GetById(command.Id);

            if (user == null)
            {
                return(new CommandResult(false, Messages.Account_NOT_FOUND, null));
            }

            NameOrDescription name = new NameOrDescription(command.Name);

            user.Update(name,
                        command.Login,
                        command.Password,
                        command.ConfirmPassword,
                        command.Nivel,
                        command.Active,
                        command.PercentM,
                        command.PercentB,
                        command.UpdatedByUserId);

            AddNotifications(user.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _UserRepository.Update(user);

            return(new CommandResult(
                       true,
                       Messages.UPDATED_WITH_SUCCESS,
                       new UserCommandResult
            {
                Id = user.Id,
                Name = user.Name.Name,
                Login = user.Login,
                Password = user.Password,
                Active = (int)user.Active,
                Nivel = user.Nivel,
                PercentM = user.PercentM,
                PercentB = user.PercentB,
                CreatedDate = user.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = user.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = user.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = user.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = user.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = user.Audit.CompanyAndBranchOffice.BranchOfficeId
            }));
        }
示例#8
0
        public void Update(NameOrDescription name, DateTime validateDate, long?updatedByUser)
        {
            Name         = name;
            ValidateDate = validateDate;

            Audit.Update(updatedByUser);

            AddNotifications(new Flunt.Validations.Contract().Requires()
                             .IsNotNull(validateDate, "validateDate", "Data requerida")
                             .IsLowerOrEqualsThan(validateDate, DateTime.Now, "ValidateDate", "Data da validade precisa ser maior que a data atua"),
                             name);
        }
示例#9
0
        public Account(NameOrDescription name, long createdByUser, CompanyAndBranchOffice companyId, string machineNameOrIP)
        {
            Name = name;

            CreatedDateBy          created = new CreatedDateBy(createdByUser);
            UpdatedDateBy          updated = new UpdatedDateBy(null);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(companyId.CompanyId, companyId.BranchOfficeId);
            Audit audit = new Audit(created, updated, companyAndBranchOffice, ERecordStatus.Active, machineNameOrIP);

            Audit = audit;

            Validate();
        }
示例#10
0
        public Contract(NameOrDescription name, DateTime validateDate, long createdByUser, CompanyAndBranchOffice companyId, string machineNameOrIP)
        {
            Name         = name;
            ValidateDate = validateDate;

            CreatedDateBy          created = new CreatedDateBy(createdByUser);
            UpdatedDateBy          updated = new UpdatedDateBy(null);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(companyId.CompanyId, companyId.BranchOfficeId);
            Audit audit = new Audit(created, updated, companyAndBranchOffice, ERecordStatus.Active, machineNameOrIP);

            Audit = audit;

            AddNotifications(new Flunt.Validations.Contract().Requires()
                             .IsNotNull(validateDate, "validateDate", "Data requerida")
                             .IsLowerOrEqualsThan(validateDate, DateTime.Now, "ValidateDate", "Data da validade precisa ser maior que a data atua"),
                             name);
        }
示例#11
0
        public async Task <ICommandResult> Handle(CreateUserCommand command)
        {
            NameOrDescription      name = new NameOrDescription(command.Name);
            CompanyAndBranchOffice companyAndBranchOffice = new CompanyAndBranchOffice(command.CompanyId, command.BranchOfficeId);
            User user = new User(name,
                                 command.Login,
                                 command.Password,
                                 command.ConfirmPassword,
                                 command.Nivel,
                                 command.PercentM,
                                 command.PercentB,
                                 command.CreatedByUserId,
                                 companyAndBranchOffice,
                                 command.MachineNameOrIP);

            AddNotifications(user.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _UserRepository.Create(user);

            return(new CommandResult(
                       true,
                       Messages.RECORDED_WITH_SUCCESS,
                       new UserCommandResult
            {
                Id = user.Id,
                Name = user.Name.Name,
                Login = user.Login,
                Password = user.Password,
                Active = (int)user.Active,
                Nivel = user.Nivel,
                PercentM = user.PercentM,
                PercentB = user.PercentB,
                CreatedDate = user.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = user.Audit.CreatedDateBy.CreatedByUserId,
                CompanyId = user.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = user.Audit.CompanyAndBranchOffice.BranchOfficeId
            }));
        }
示例#12
0
        public async Task <ICommandResult> Handle(EditCallGroupCommand command)
        {
            CallGroup CallGroup = await _CallGroupRepository.GetById(command.Id);

            if (CallGroup == null)
            {
                return(new CommandResult(false, Messages.Account_NOT_FOUND, null));
            }

            NameOrDescription name = new NameOrDescription(command.Name);

            CallGroup.Update(name, command.UpdatedByUserId);

            AddNotifications(name.Notifications);
            AddNotifications(CallGroup.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _CallGroupRepository.Update(CallGroup);

            return(new CommandResult(
                       true,
                       Messages.UPDATED_WITH_SUCCESS,
                       new CallGroupCommandResult
            {
                Id = CallGroup.Id,
                Name = CallGroup.Name.Name,
                CreatedDate = CallGroup.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = CallGroup.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = CallGroup.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = CallGroup.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = CallGroup.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = CallGroup.Audit.CompanyAndBranchOffice.BranchOfficeId,
                MachineNameOrIP = CallGroup.Audit.MachineNameOrIP
            }));
        }
示例#13
0
        public async Task <ICommandResult> Handle(EditAccountCommand command)
        {
            Account account = await _accountRepository.GetById(command.Id);

            if (account == null)
            {
                return(new CommandResult(false, Messages.Account_NOT_FOUND, null));
            }

            NameOrDescription name = new NameOrDescription(command.Name);

            account.Update(name, command.UpdatedByUserId);

            AddNotifications(name.Notifications);
            AddNotifications(account.Notifications);

            if (!Valid)
            {
                return(new CommandResult(
                           false,
                           Messages.NOTIFICATIONS,
                           Notifications));
            }

            await _accountRepository.Update(account);

            return(new CommandResult(
                       true,
                       Messages.UPDATED_WITH_SUCCESS,
                       new AccountCommandResult
            {
                Id = account.Id,
                Name = account.Name.Name,
                CreatedDate = account.Audit.CreatedDateBy.CreatedDate,
                CreatedByUserId = account.Audit.CreatedDateBy.CreatedByUserId,
                UpdatedDate = account.Audit.UpdatedDateBy.UpdatedDate,
                UpdatedByUserId = account.Audit.UpdatedDateBy.UpdatedByUserId,
                CompanyId = account.Audit.CompanyAndBranchOffice.CompanyId,
                BranchOfficeId = account.Audit.CompanyAndBranchOffice.BranchOfficeId
            }));
        }
示例#14
0
        public void Update(NameOrDescription name,
                           string login,
                           string password,
                           string confirmPassword,
                           long nivel,
                           long active,
                           decimal percentM,
                           decimal percentB,
                           long?updatedByUser)
        {
            Name             = name;
            Login            = login;
            Password         = password;
            _confirmPassword = confirmPassword;
            Active           = (EActiveDeactive)active;
            Nivel            = nivel;
            PercentM         = percentM;
            PercentB         = percentB;

            Audit.Update(updatedByUser);
            Validate();
        }
示例#15
0
        public void Update(long callTypeId,
                           long callGroupId,
                           long sectorId,
                           long agreementId,
                           long customerId,
                           long employeeId,
                           EPriority priority,
                           NameOrDescription title,
                           string details,
                           long updatedByUserId)
        {
            CallTypeId  = callTypeId;
            CallGroupId = callGroupId;
            SectorId    = sectorId;
            ContractId  = agreementId;
            CustomerId  = customerId;
            EmployeeId  = employeeId;
            Priority    = priority;
            Details     = details;

            Title = title;
            Audit.Update(updatedByUserId);
            Validate();
        }