Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "KCId,SpecieId,DayAfterSowing,Coefficient")] KC kC)
        {
            if (ModelState.IsValid)
            {
                db.KCs.Add(kC);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SpecieId = new SelectList(db.Species, "SpecieId", "Name", kC.SpecieId);
            return(View(kC));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Импорт фотографий клиентов
        /// </summary>
        public static void ImportClientPhotos()
        {
            string mainPath = @"C:\Users\Student\Desktop\09_1.1_3\Сессия 1\";

            using (var context = new LanguageContext())
            {
                var clients = context.Client.ToList();

                var fileNames = File.ReadAllLines(@"C:\Users\Student\source\repos" +
                                                  @"\LanguageSchool\LanguageSchool\Resources\ClientPaths.txt");

                for (int i = 0; i < clients.Count; i++)
                {
                    clients[i].Photo = File.ReadAllBytes(mainPath + fileNames[i]);
                }

                context.SaveChanges();
            }
        }