public void InsertMechanic(MechanicViewModel mechanic, int userId)
        {
            Mechanic entity = new Mechanic();

            Map(mechanic, entity);
            entity.CreateUserId = entity.ModifyUserId = userId;
            entity.CreateDate   = entity.ModifyDate = DateTime.Now;
            entity.Status       = (int)DbConstant.DefaultDataStatus.Active;
            _mechanicRepository.Add(entity);
            _unitOfWork.SaveChanges();
        }
Example #2
0
        public bool approveMechanic(Application application)
        {
            var mechanic = new Mechanic();
            var holder   = applicationRepository.Update(application);

            if (holder)
            {
                mechanic.firstName   = application.firstName;
                mechanic.lastName    = application.lastName;
                mechanic.username    = application.username;
                mechanic.phoneNumber = application.phoneNumber;
                mechanic.password    = application.password;
                mechanic.email       = application.email;
                mechanic.GarageId    = application.GarageId;
            }

            return(mechanicRepository.Add(mechanic));
        }
Example #3
0
        Guid IMechanicService.RegisterMechanic(RegisterMechanicViewModel model)
        {
            _unitOfWork.BeginTransaction();

            var mechanic = new Mechanic(model.UserName, model.Password, model.Email, model.CompanyName, model.City, model.Country, model.PostalCode, model.Address);

            if (_mechanicRepository.emailTaken(mechanic))
            {
                _unitOfWork.Commit();
                throw new Exception(ExceptionMessages.MechanicException.EMAIL_TAKEN);
            }
            var isTaken = _mechanicRepository.userNameTaken(mechanic);

            if (isTaken)
            {
                _unitOfWork.Commit();
                throw new Exception(ExceptionMessages.MechanicException.USERNAME_TAKEN);
            }

            _mechanicRepository.Add(mechanic);
            _unitOfWork.Commit();

            return(mechanic.Id);
        }