Ejemplo n.º 1
0
        public bool DeleteRCORegistration(RCORegistration registration)
        {
            this.dbContext.RCORegistrations.Remove(registration);
            var result = this.dbContext.SaveChanges();

            return(result != 0);
        }
Ejemplo n.º 2
0
        public RCORegistration UpdateRegistration(RCORegistration rcoRegistration)
        {
            this.dbContext.RCORegistrations.Update(rcoRegistration);
            this.dbContext.SaveChanges();

            return(rcoRegistration);
        }
Ejemplo n.º 3
0
        public RCORegistration CreateRCORegistration(RCORegistration rcoRegistration)
        {
            this.dbContext.RCORegistrations.Add(rcoRegistration);
            this.dbContext.SaveChanges();

            return(rcoRegistration);
        }
Ejemplo n.º 4
0
        public RCORegistrationModel SaveRegistration(RCORegistrationModel registrationModel)
        {
            var userExist = this.userService.IsUserExists(registrationModel.EmailId);

            if (userExist)
            {
                throw new UserAlreadyExistsException($"User with email {registrationModel.EmailId} already exist.");
            }

            var department = this.departmentRepository.GetDepartmentById(registrationModel.DepartmentId);

            if (department == null)
            {
                throw new InvalidInputException("DepartmentId is not valid.");
            }

            var registration = new RCORegistration();

            registration.AdminName        = registrationModel.AdminName;
            registration.ContactNumber    = registrationModel.ContactNumber;
            registration.DepartmentID     = registrationModel.DepartmentId;
            registration.Designation      = registrationModel.Designation;
            registration.District         = registrationModel.District;
            registration.EmailID          = registrationModel.EmailId;
            registration.OfficeAddress1   = registrationModel.OfficeAddress1;
            registration.OfficeAddress2   = registrationModel.OfficeAddress2;
            registration.RegistrationType = registrationModel.RegistrationType;
            registration.TINNumber        = registrationModel.TINNumber;
            registration.TANNumber        = registrationModel.TANNumber;
            registration.CreatedDate      = DateTime.Now;

            this.repository.CreateRCORegistration(registration);

            var user = new User();

            user.EmailID      = registrationModel.EmailId;
            user.UserType     = UserType.RCOUser;
            user.MobileNumber = registrationModel.ContactNumber;
            user.DepartmentID = registrationModel.DepartmentId;

            this.userService.CreateUser(user, PasswordGenerator.GenerateRandomPassword(8));

            return(registrationModel);
        }