Beispiel #1
0
        public async Task <IActionResult> PutBusinessType(int id, BusinessType businessType)
        {
            if (id != businessType.id)
            {
                return(BadRequest());
            }

            _context.Entry(businessType).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BusinessTypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutFeedback(int id, Feedback feedback)
        {
            if (id != feedback.Id)
            {
                return(BadRequest());
            }

            _context.Entry(feedback).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FeedbackExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
        public async Task <ActionResult <Values> > Post([FromBody] Values values)
        {
            _context.Values.Add(values);
            await _context.SaveChangesAsync();

            return(values);
        }
Beispiel #4
0
        public async Task <ActionResult> AddCategory(Category category)
        {
            category.isVisible = true;
            await _context.Categories.AddAsync(category);

            await _context.SaveChangesAsync();

            return(new OkObjectResult("Category Added Sucessfully"));
        }
        public async Task <ActionResult> AddQuestionOption(QuestionOptions questionOptions)
        {
            questionOptions.isVisible = true;
            _context.QuestionOptions.Add(questionOptions);

            await _context.SaveChangesAsync();

            return(new OkObjectResult("Question Option Inserted Sucessfully"));
        }
Beispiel #6
0
        public async Task <ActionResult> AddQuestion(Question question)
        {
            question.isVisible = true;
            await _context.Questions.AddAsync(question);

            await _context.SaveChangesAsync();

            return(new OkObjectResult("Question Added Sucessfully"));
        }
Beispiel #7
0
        public async Task <ActionResult> AddBusiness(Business business, string token)
        {
            business.isVisible = true;
            business.OwnerId   = utils.ParseToken(token).id;
            if (await userManager.FindByIdAsync(business.OwnerId) != null)
            {
                await context.Businesses.AddAsync(business);

                await context.SaveChangesAsync();

                return(new OkObjectResult(new { message = "Business Added Sucessfully" }));
            }
            else
            {
                return(new BadRequestObjectResult(new { message = "Invalid Owner Id" }));
            }
        }
Beispiel #8
0
        public async Task <ActionResult> SignUp(RegisterViewModel registerViewModel)
        {
            IdentityRole role;
            var          user = new ApplicationUser
            {
                UserName    = registerViewModel.email,
                name        = registerViewModel.name,
                PhoneNumber = registerViewModel.phone,
                Email       = registerViewModel.email,
                city        = registerViewModel.city,
                country     = registerViewModel.country
            };

            if (registerViewModel.business != null)
            {
                role = await roleManager.FindByNameAsync("Admin");
            }
            else
            {
                role = await roleManager.FindByNameAsync("Customer");
            }
            if (role != null)
            {
                var result = await userManager.CreateAsync(user, registerViewModel.password);

                if (result.Succeeded)
                {
                    var token = await userManager.GenerateEmailConfirmationTokenAsync(user);

                    var confirmationLink = Url.Action("ConfirmEmail", "Account",
                                                      new { userId = user.Id, token = token }, Request.Scheme);
                    var roleAddingResult = await userManager.AddToRoleAsync(user, role.Name);

                    if (roleAddingResult.Succeeded)
                    {
                        // var response = await _accountRepository.EmailConfirmation(user.Email,"Verify this Email by clicking the Button Below to Continue using Taste Clicks", confirmationLink);


                        // utils.sendMail(registerViewModel.email, confirmationLink, "Please Click Below Button to Verify your email and continue using Taste Clicks", "Please Verify your Email to continue using Taste Clicks");
                        if (registerViewModel.business != null)
                        {
                            string path      = Path.Combine(_env.ContentRootPath, "images");
                            string imageName = Guid.NewGuid() + ".png";
                            //set the image path
                            string imgPath = Path.Combine(path, imageName);
                            try
                            {
                                if (registerViewModel.business.Image != null)
                                {
                                    byte[] imageBytes = Convert.FromBase64String(registerViewModel.business.Image);

                                    System.IO.File.WriteAllBytes(imgPath, imageBytes);

                                    registerViewModel.business.Image = $"{Request.Scheme}://{Request.Host}{Request.PathBase}/images/{imageName}";
                                }
                            }
                            catch (Exception e)
                            {
                                return(BadRequest(e.Message));
                            }
                            registerViewModel.business.isVisible = true;
                            registerViewModel.business.OwnerId   = user.Id;

                            _context.Businesses.Add(registerViewModel.business);

                            await _context.SaveChangesAsync();
                        }

                        return(new OkObjectResult("verification Email is sent on your mentioned email address please verify to Continue"));
                    }
                    else
                    {
                        foreach (var error in roleAddingResult.Errors)
                        {
                            sb.Append(error.Description + "\n");
                        }
                    }
                    return(new BadRequestObjectResult(sb.ToString()));
                }

                else
                {
                    foreach (var error in result.Errors)
                    {
                        sb.Append(error.Description + "\n");
                    }
                }
                return(new BadRequestObjectResult(sb.ToString()));
            }
            else
            {
                return(new BadRequestObjectResult("Role Does not Exist"));
            }
        }