public ActionResult Form(FormularzViewModel model)
        {
            SpisContext DTB = new SpisContext();

            if (ModelState.IsValid)
            {
                int id = (from p in DTB.Phones where p.phone_number == model.PHONE_NUMBER select p.id_phone).First();
                var DK = model.DoKogo;
                var TO = model.TelefonyUsera;

                var userID = User.Identity.GetUserId();
                //int myChosePhone=100;
                //string a = model.SelectedTelefon;
                //int parsedInt = 0;
                //if (int.TryParse(a, out parsedInt))
                //    myChosePhone = parsedInt;



                Call call = new Call
                {
                    date           = model.Date,
                    description    = model.Description,
                    callerName     = model.NameCaller,
                    callerLastName = model.LastNaemCaller,
                    status         = false,
                    adresseID      = model.SelectedDoKogo,
                    caller_number  = model.PHONE_NUMBER_CALLER,
                    id_phone       = id,
                    dataDodania    = DateTime.Now,
                    UserID         = userID,
                };
                DTB.Calls.Add(call);
                DTB.SaveChanges();


                //var newCall = CallMenager.CreateCall(call, userID);
                return(RedirectToAction("CallList_TylkoDlaMnie", "Call"));
            }


            else
            {
                return(View(model));
            }
        }
        public async Task <ActionResult> Form()
        {
            if (Request.IsAuthenticated)
            {
                SpisContext DTB = new SpisContext();

                //SpisContext db = new SpisContext();

                // model.Phones = new SelectList(db.Phones, "phone_number");

                //var modelDDL = new ListPhoneView()
                //{
                //    Telefony = db.Phones.Select(x => new SelectListItem
                //    {
                //        Value = x.id_phone.ToString(),
                //        Text = x.phone_number

                var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                var userID = User.Identity.GetUserId();
                FormularzViewModel model = new FormularzViewModel();
                model.DoKogo = DTB.Users.Select(x => new SelectListItem
                {
                    Value = x.Id,
                    Text  = x.UserData.lastName + " " + x.UserData.name
                });

                model.TelefonyUsera = DTB.Phones.Select(y => new SelectListItem
                {
                    Value = y.id_phone.ToString(),
                    Text  = y.phone_number
                });



                //    })

                //};
                //if (Request.IsAuthenticated)
                if (ModelState.IsValid)
                {
                    //var user = await UserManager.FindByIdAsync(User.Identity.GetUserId());
                    //var userID = User.Identity.GetUserId();

                    //model.Telefony = db.Phones.Select(x => new SelectListItem
                    //{
                    //    Value = x.id_phone.ToString(),
                    //    Text = x.phone_number
                    //});
                    //int id = (from p in db.Phones where p.phone_number == model.PHONE_NUMBER select p.id_phone).First();



                    return(View(model));
                }
                else
                {
                    return(View(model));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }