示例#1
0
        public int?RegisterUser(UserRegistration registration, LoggedInUser loggedInUser, List <ValidationMessage> validationMessages)
        {
            if (!CommonValidationHelper.ValidateLoggedInUser(loggedInUser, validationMessages))
            {
                return(null);
            }

            var station = new Station {
                Name = registration.StationName, StationCode = registration.StationCode, Address = registration.Address, MobileNumber = registration.MobileNumber
            };
            var stationId = _stationsRepository.AddStation(station, validationMessages);

            if (stationId != null)
            {
                var userDetails = new UserDetails {
                    Username = registration.UserName, Password = registration.Password, Email = registration.Email, IsAdmin = registration.IsAdmin
                };
                var userId   = _userRepository.AddUser(userDetails, validationMessages);
                var supplier = new Supplier {
                    FirstName = registration.FirstName, LastName = registration.LastName, Address = registration.Address, MobileNumber = registration.MobileNumber, StationId = stationId ?? 0, UserId = userId
                };
                var supplierId = _suppliersRepository.AddSupplier(supplier, validationMessages);
                return(userId);
            }

            return(null);
        }
示例#2
0
 public bool?DeleteSupplier(int suplierId, LoggedInUser loggedInUser, List <ValidationMessage> validationMessages)
 {
     if (!CommonValidationHelper.ValidateLoggedInUser(loggedInUser, validationMessages))
     {
         return(null);
     }
     return(_suppliersRepository.DeleteSupplier(suplierId, validationMessages));
 }
示例#3
0
        public List <Supplier> GetSuppliers(LoggedInUser loggedInUser, List <ValidationMessage> validationMessages)
        {
            if (!CommonValidationHelper.ValidateLoggedInUser(loggedInUser, validationMessages))
            {
                return(null);
            }
            var result = _suppliersRepository.GetSuppliersList(loggedInUser.StationId ?? 0, validationMessages);

            return(result);
        }
示例#4
0
        public int?AddStation(Station station, LoggedInUser loggedInUser, List <ValidationMessage> validationMessages)
        {
            if (!CommonValidationHelper.ValidateLoggedInUser(loggedInUser, validationMessages))
            {
                return(null);
            }
            var result = _stationsRepo.AddStation(station, validationMessages);

            return(result);
        }
示例#5
0
        public List <Station> GetStationsList(LoggedInUser loggedInUser, List <ValidationMessage> validationMessages)
        {
            if (!CommonValidationHelper.ValidateLoggedInUser(loggedInUser, validationMessages))
            {
                return(null);
            }
            var result = _stationsRepo.GetStationsList(validationMessages);

            return(result);
        }
示例#6
0
        public int?UpsertSupplier(Supplier supplier, LoggedInUser loggedInUser, List <ValidationMessage> validationMessages)
        {
            if (!CommonValidationHelper.ValidateLoggedInUser(loggedInUser, validationMessages))
            {
                return(null);
            }

            supplier.StationId = loggedInUser.StationId ?? 0;
            var result = _suppliersRepository.AddSupplier(supplier, validationMessages);

            return(result);
        }