コード例 #1
0
        public IHttpActionResult PutOoredo(int id, Ooredo ooredo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != ooredo.Id)
            {
                return(BadRequest());
            }

            db.Entry(ooredo).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OoredoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "Id,x,y,address,title")] Ooredo ooredo)
        {
            if (ModelState.IsValid)
            {
                db.Ooredoes.Add(ooredo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(ooredo));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "YazarId,YazarAdiSoyadi,YazarDogumTarihi")] Yazar yazar)
        {
            if (ModelState.IsValid)
            {
                db.Yazars.Add(yazar);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(yazar));
        }
コード例 #4
0
        public ActionResult Create([Bind(Include = "Id,A")] Class1 class1)
        {
            if (ModelState.IsValid)
            {
                db.Class1.Add(class1);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(class1));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "PersonID,FirstName,LastName")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(person));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "EmployeeId,FirstName,LastName,Email")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "dataId,descriere")] Data data)
        {
            if (ModelState.IsValid)
            {
                db.Data.Add(data);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.dataId = new SelectList(db.Vanzares, "vanzareId", "vanzareId", data.dataId);
            return(View(data));
        }
コード例 #8
0
        public ActionResult Create([Bind(Include = "clientId,descriere")] Client client)
        {
            if (ModelState.IsValid)
            {
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.clientId = new SelectList(db.Vanzares, "vanzareId", "vanzareId", client.clientId);
            return(View(client));
        }
コード例 #9
0
        public ActionResult Create([Bind(Include = "locatieId,descriere")] Locatie locatie)
        {
            if (ModelState.IsValid)
            {
                db.Locaties.Add(locatie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.locatieId = new SelectList(db.Vanzares, "vanzareId", "vanzareId", locatie.locatieId);
            return(View(locatie));
        }
コード例 #10
0
        public ActionResult Create([Bind(Include = "produsId,descriere")] Produs produs)
        {
            if (ModelState.IsValid)
            {
                db.Produs.Add(produs);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.produsId = new SelectList(db.Vanzares, "vanzareId", "vanzareId", produs.produsId);
            return(View(produs));
        }
コード例 #11
0
        public ActionResult Create([Bind(Include = "vanzareId,produsId,locatieId,dataId,clientId,pret,cantitate")] Vanzare vanzare)
        {
            if (ModelState.IsValid)
            {
                db.Vanzares.Add(vanzare);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.vanzareId = new SelectList(db.Clients, "clientId", "descriere", vanzare.vanzareId);
            ViewBag.vanzareId = new SelectList(db.Data, "dataId", "descriere", vanzare.vanzareId);
            ViewBag.vanzareId = new SelectList(db.Locaties, "locatieId", "descriere", vanzare.vanzareId);
            ViewBag.vanzareId = new SelectList(db.Produs, "produsId", "descriere", vanzare.vanzareId);
            return(View(vanzare));
        }
コード例 #12
0
        public WeatherApi weather_thread(string city)
        {
            var myWeatherTask = getWeather(city);

            myWeatherTask.Wait();
            WeatherApi myWeather = myWeatherTask.Result;


            string dataTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");


            var contextOptions = new DbContextOptionsBuilder <WebApplication3Context>()
                                 .UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=WebApplication3Context-6c28e34d-e6cb-4189-9bb9-60ff82f2a08f;Trusted_Connection=True;MultipleActiveResultSets=true")
                                 .Options;
            var context = new WebApplication3Context(contextOptions);

            var weath = new Models.weather();

            weath.name        = myWeather.name;
            weath.temp        = Math.Round(myWeather.main.temp - 273.15, 1);
            weath.datatime    = dataTime;
            weath.description = myWeather.weather[0].description;
            context.Add(weath);
            context.SaveChanges();


            return(myWeather);
        }
コード例 #13
0
        public ActionResult Create([Bind(Include = "Id,Username,Password,Email,Phone,Code,Status")] Users users)
        {
            if (ModelState.IsValid)
            {
                string randomCode = Path.GetRandomFileName();
                randomCode   = randomCode.Replace(".", "");
                users.Status = UserStatus.Deactivate;
                users.Code   = randomCode;
                db.Users.Add(users);
                db.SaveChanges();
                SendSmsController sendSmsController = new SendSmsController();
                sendSmsController.SendSms(randomCode);
                return(RedirectToAction("Verify"));
            }

            return(View(users));
        }