public async Task <VendorVM> Handle(AddVendorCommand request, CancellationToken cancellationToken)
        {
            var data = new Vendor()
            {
                Address        = request.Address,
                City           = request.City,
                ContactNumbers = request.ContactNumbers,
                MailId         = request.MailId,
                Name           = request.Name,
                Pin            = request.Pin,
            };

            foreach (var v in request.ServicesProvided)
            {
                data.ServicesProviede.Add(new VendorAndServices()
                {
                    //ServiceDetails = v,
                    ServiceId = v.Id,
                    //VendorDetails = data,
                    VendorID = data.Id
                });
            }
            _context.VendorRecord.Add(data);
            await _context.SaveChangesAsync(cancellationToken);

            return(request);
        }
        public async Task <Institute> Handle(CreateInstituteCommand request, CancellationToken cancellationToken)
        {
            _context.InstituteRecord.Add(request);
            await _context.SaveChangesAsync(cancellationToken);

            return(request);
        }
        public async Task <int> Handle(CreateNewUserCommand request, CancellationToken cancellationToken)
        {
            byte[] pwdH;
            byte[] pwdS;
            Uttility.CreateHashedPassword(request.Password, out pwdH, out pwdS);
            var entity = new User()
            {
                UserName = request.userId,
                ChangePasswordAtLogin = request.ChangePasswordAtLogin,
                ContactNumber         = request.ContactNumber,
                IsUserLocked          = false,
                MaxLoginTryAllowed    = request.MaxLoginTryAllowed,
                UserDetails           = new UserDetailInformation()
                {
                    Email     = request.mailId,
                    FirstName = request.FirstName,
                    LastName  = request.LastName
                },
                UserRoles = request.Roles.Select(r => new Roles {
                    RoleName = r
                }).ToList(),
                PasswordHash = pwdH,
                PasswordSalt = pwdS
            };

            _dbContext.UserRecrds.Add(entity);
            await _dbContext.SaveChangesAsync(cancellationToken);

            return(entity.Id);
        }
        public async Task <Service> Handle(AddServiceCommand request, CancellationToken cancellationToken)
        {
            Service s = new Service()
            {
                ServiceName = request.ServiceName
            };

            _context.ServiceRecord.Add(s);
            await _context.SaveChangesAsync(cancellationToken);

            return(s);
        }
Пример #5
0
        public async Task <UserVM> Handle(UpddateUserCommand request, CancellationToken cancellationToken)
        {
            var user = _dbContext.UserRecrds.Include(d => d.UserDetails)
                       .Include(r => r.UserRoles).FirstOrDefault(x => x.UserName == request.userId);

            user.ContactNumber         = request.ContactNumber;
            user.UserDetails.Email     = request.mailId;
            user.UserDetails.FirstName = request.FirstName;
            user.UserDetails.LastName  = request.LastName;
            user.ChangePasswordAtLogin = request.ChangePasswordAtLogin;
            await _dbContext.SaveChangesAsync(cancellationToken);

            return(_mapper.Map <UserVM>(user));
        }
        public async Task <Institute> Handle(UpdateInstituteCommand request, CancellationToken cancellationToken)
        {
            var result = await(from i in _context.InstituteRecord
                               where i.Id == request.Id
                               select i).FirstOrDefaultAsync();

            if (result == null)
            {
                return(null);
            }
            result.EstablishedOn  = request.EstablishedOn;
            result.Address        = request.Address;
            result.AllowedGender  = request.AllowedGender;
            result.City           = request.City;
            result.ContactNumbers = request.ContactNumbers;
            result.EstablishedOn  = request.EstablishedOn;
            result.MailId         = request.MailId;
            result.Name           = request.Name;
            result.Pin            = request.Pin;
            result.Website        = request.Website;
            await _context.SaveChangesAsync(cancellationToken);

            return(result);
        }