Esempio n. 1
0
        public async Task <ActionResult <List <User> > > GetUsersOfATenent(Guid tenentId)
        {
            if (await _tenentRepo.GetById(tenentId) == null)
            {
                return(NotFound("tenent Not Found"));
            }
            List <User> users = (await this._Userrepo.GetListBasedOnCondition(x => x.Tenent.Id == tenentId)).ToList();

            return(users);
        }
Esempio n. 2
0
        public async Task <ActionResult> UpdateContact(Guid tenetId, Guid userId, Guid contactId, DtoContact dtoupdatecontact)
        {
            if (await _tenentRepo.GetById(tenetId) == null)
            {
                return(BadRequest("tenent not found"));
            }
            if (await _userRepo.GetById(userId) == null)
            {
                return(BadRequest("user not found"));
            }
            if (await _contactRepo.GetById(contactId) == null)
            {
                return(BadRequest("contact not found"));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest("Information provided is not valid"));
            }

            Contact contact = await this._contactRepo.FirstOrDefault(x => x.Id == contactId && x.User.Id == userId);

            contact.Name     = dtoupdatecontact.Name;
            contact.Mobileno = dtoupdatecontact.MobileNo;
            await this._contactRepo.update(contact);

            return(Ok("Updated Successfully"));
        }
Esempio n. 3
0
        public async Task <ActionResult <List <Contact> > > GetAllContact(Guid tenentId, Guid userId)
        {
            if (await _tenentRepo.GetById(tenentId) == null)
            {
                return(BadRequest("tenent not found"));
            }
            if (await _userRepo.GetById(userId) == null)
            {
                return(BadRequest("user not found"));
            }
            List <Contact> contacts = (await this._contactRepo.GetListBasedOnCondition(
                                           x => x.User.Tenent.Id == tenentId &&
                                           x.User.Id == userId)).ToList();

            return(contacts);
        }
Esempio n. 4
0
        //       [SampleJwtAuthorization(Role = new string[] { "superadmin", "Admin" })]
        public async Task <ActionResult> UpdateUser(Guid tenentId, Guid userId, DtoUser usertobeupdated)
        {
            if (await _tenentRepo.GetById(tenentId) == null)
            {
                return(BadRequest("Tenent not found"));
            }
            if (await _Userrepo.GetById(userId) == null)
            {
                return(BadRequest("User not found"));
            }
            var user = await _Userrepo.FirstOrDefault(x => x.Id == userId && x.Tenent.Id == tenentId);

            user.UserName = usertobeupdated.UserName;
            user.Password = usertobeupdated.Password;
            user.Role     = usertobeupdated.Role;
            await this._Userrepo.update(user);

            return(Ok("user Updated Successfully"));
        }