コード例 #1
0
        public async Task <IActionResult> CreatOrder(OrderViewModel model)
        {
            var user = await _userManager.GetUserAsync(User);

            if (user == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'.");
            }

            if (ModelState.IsValid)
            {
                UserOrder order = new UserOrder
                {
                    PodCityId    = model.CityId,
                    PodServiceId = model.ServiceId,
                    Price        = model.Price,
                    Description  = model.Description,
                    TypeService  = model.TypeService,
                    Datetime     = model.Datetime,
                    UserId       = user.Id
                };

                if (order != null)
                {
                    await db.UserOrders.AddAsync(order);

                    await db.SaveChangesAsync();

                    return(RedirectToAction("My_Order", "CustomManage"));
                }
            }
            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> DeleteUser(string Id)
        {
            if (Id != null)
            {
                User user = await _userManager.FindByIdAsync(Id);

                if (user != null)
                {
                    IEnumerable <Photo> photo = await db.Photos.Where(p => p.UserId == user.Id).ToListAsync();

                    if (photo != null)
                    {
                        db.Photos.RemoveRange(photo);
                    }
                    IEnumerable <UserOrder> uo = await db.UserOrders.Where(p => p.UserId == user.Id).ToListAsync();

                    if (uo != null)
                    {
                        db.UserOrders.RemoveRange(uo);
                    }
                    IEnumerable <Chat> chat = await db.Chats.Where(p => p.UserId == user.Id).ToListAsync();

                    if (chat != null)
                    {
                        db.Chats.RemoveRange(chat);
                    }
                    IEnumerable <Chat> chat2 = await db.Chats.Where(p => p.UserUser == user.Id).ToListAsync();

                    if (chat2 != null)
                    {
                        db.Chats.RemoveRange(chat2);
                    }
                    IEnumerable <Video> video = await db.Videos.Where(p => p.UserId == user.Id).ToListAsync();

                    if (video != null)
                    {
                        db.Videos.RemoveRange(video);
                    }
                    IEnumerable <Chosen> ch = await db.Chosens.Where(p => p.UserId == user.Id).ToListAsync();

                    if (ch != null)
                    {
                        db.Chosens.RemoveRange(ch);
                    }

                    await _userManager.DeleteAsync(user);

                    await db.SaveChangesAsync();
                }
            }
            return(RedirectToAction("Users", "Admin"));
        }
コード例 #3
0
        public async Task <IActionResult> Profil(string id, ProfilViewModel model)
        {
            User user = await _userManager.Users.SingleOrDefaultAsync(p => p.Id == id);

            if (user != null)
            {
                IQueryable <UserService> userservices = db.UserServices.Where(p => p.UserId == id).Include(o => o.PodCity).Include(o => o.PodService).Include(o => o.User);
                model.UserServices = await userservices.ToListAsync();

                IQueryable <Photo> photo = db.Photos.Where(p => p.UserId == user.Id);
                model.Photo = await photo.ToListAsync();

                IQueryable <Video> video = db.Videos.Where(p => p.UserId == user.Id);
                model.Video = await video.ToListAsync();

                IQueryable <Review> reviews = db.Reviews.Where(p => p.UserId == user.Id);
                model.Review = await reviews.ToListAsync();

                PodCity city = await db.PodCities.SingleOrDefaultAsync(p => p.Id == user.PodCityId);

                model.City        = city.Name;
                model.Id          = user.Id;
                model.Email       = user.Fio;
                model.PhoneNumber = user.PhoneNumber;
                model.PhotoUrl    = user.Avatar;
                user.View        += 1;
                await db.SaveChangesAsync();
            }
            return(View(model));
        }
コード例 #4
0
 public async Task <IActionResult> New_Order(string Id, int?did)
 {
     if (Id != null && did != null)
     {
         var dr = db.DirectOrders.FirstOrDefault(p => p.Id == did);
         if (Id == "ttrue")
         {
             dr.TrueFolse = true;
             await db.SaveChangesAsync();
         }
         else
         {
             dr.TrueFolse = false;
             await db.SaveChangesAsync();
         }
     }
     return(RedirectToAction("New_Order", "Manage"));
 }
コード例 #5
0
        public async Task <IActionResult> Accounty(PhoneViewModel model, string role, string Number, bool?truefalse)
        {
            if (ModelState.IsValid && Number != null)
            {
                var num = await db.SmsCodes.FirstOrDefaultAsync(p => p.NewPhoneNumber == model.Number);

                if (num != null)
                {
                    db.SmsCodes.Remove(num);
                }

                var user = await _userManager.Users.FirstOrDefaultAsync(p => p.PhoneNumber == model.Number);

                if (user != null)
                {
                    ModelState.AddModelError("", "Токой номер уже существует! Если это ваш намер, тогда нажмите на ссылку <<Забыл пороль>>");
                    return(View(model));
                }

                Number = model.Number;
                gert   = ran.Next(11111, 66666);

                HttpWebRequest         myReq            = (HttpWebRequest)WebRequest.Create($"https://sms.ru/sms/send?api_id=70E095C7-C999-495D-31B6-5FBE4AB00C59&to={model.Number}&msg={gert}&json=1");
                HttpWebResponse        myResp           = (HttpWebResponse)myReq.GetResponse();
                System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
                string responseString = respStreamReader.ReadToEnd();
                respStreamReader.Close();
                myResp.Close();


                SmsCode sms = new SmsCode {
                    NewPhoneNumber = model.Number, SMSCode = gert.ToString()
                };
                await db.SmsCodes.AddAsync(sms);

                await db.SaveChangesAsync();

                return(RedirectToAction("Register", "Account", new { role, model.Number }));
            }
            return(View(model));
        }