Пример #1
0
        public async Task <IActionResult> PutPozycja(int id, Pozycja pozycja)
        {
            if (id != pozycja.PozycjaId)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PozycjaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(NoContent());
        }
Пример #2
0
        public ActionResult Edit(Skola skola, HttpPostedFileBase image1)
        {
            skola.Fotografija = new byte[image1.ContentLength];
            Stream fs = image1.InputStream;

            fs.Read(skola.Fotografija, 0, image1.ContentLength);

            try
            {
                db.Entry(skola).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("ViewAdmin", "Login"));
            }
            catch (Exception)
            {
                throw;
            }
        }
 public ActionResult Edit([Bind(Include = "Jmbg,Ime,Prezime,BrLicneKarte,MjestoStanovanja")] Glasac glasac)
 {
     if (ModelState.IsValid)
     {
         db.Entry(glasac).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(glasac));
 }
Пример #4
0
 public ActionResult Edit([Bind(Include = "Id")] GlasackiListic glasackiListic)
 {
     if (ModelState.IsValid)
     {
         db.Entry(glasackiListic).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(glasackiListic));
 }
 public ActionResult Edit([Bind(Include = "LokacijaMjesta")] GlasackoMjesto glasackoMjesto)
 {
     if (ModelState.IsValid)
     {
         db.Entry(glasackoMjesto).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(glasackoMjesto));
 }
Пример #6
0
 public ActionResult Edit([Bind(Include = "JMBG,Ime,Prezime,Mjesto_stanovanja,N")] Kandidat kandidat)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kandidat).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kandidat));
 }
Пример #7
0
 public ActionResult Edit([Bind(Include = "JanrId,janr_nomi")] Janr janr)
 {
     if (ModelState.IsValid)
     {
         db.Entry(janr).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(janr));
 }
 public ActionResult Edit([Bind(Include = "Naziv")] Utrka utrka)
 {
     if (ModelState.IsValid)
     {
         db.Entry(utrka).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(utrka));
 }
Пример #9
0
 public ActionResult Edit([Bind(Include = "XodimId,familiya,ismi,sharifi,login,parol")] Xodim xodim)
 {
     if (ModelState.IsValid)
     {
         db.Entry(xodim).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(xodim));
 }
Пример #10
0
 public ActionResult Edit([Bind(Include = "KitobxonId,familiya,ismi,sharifi,tugilgan_yili,millati,passport_seriya,passport_nomer,adress,telefon")] Kitobxon kitobxon)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kitobxon).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kitobxon));
 }
Пример #11
0
 public ActionResult Edit([Bind(Include = "ImeSubjekta")] PSubjekat pSubjekat)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pSubjekat).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pSubjekat));
 }
Пример #12
0
 public ActionResult Edit([Bind(Include = "KitobId,nomi,chop_etilg_yil,avtor,JanrId,nashriyot,betlar_soni,soni,rasmi,qisqacha_malumot")] Kitob kitob)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kitob).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.JanrId = new SelectList(db.Janrs, "JanrId", "janr_nomi", kitob.JanrId);
     return(View(kitob));
 }
Пример #13
0
 public ActionResult Edit([Bind(Include = "Foyd_ber_kitoblarId,XodimId,KitobxonId,KitobId,berilgan_vaqti,qaytarilish_vaqti")] Foyd_ber_kitoblar foyd_ber_kitoblar)
 {
     if (ModelState.IsValid)
     {
         db.Entry(foyd_ber_kitoblar).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.KitobId    = new SelectList(db.Kitobs, "KitobId", "nomi", foyd_ber_kitoblar.KitobId);
     ViewBag.KitobxonId = new SelectList(db.Kitobxons, "KitobxonId", "familiya", foyd_ber_kitoblar.KitobxonId);
     ViewBag.XodimId    = new SelectList(db.Xodims, "XodimId", "familiya", foyd_ber_kitoblar.XodimId);
     return(View(foyd_ber_kitoblar));
 }
Пример #14
0
        public async Task <Object> DeleteFlightFromList(int id)
        {
            string userRole = User.Claims.ElementAt(1).Value;

            if (userRole == "AirlineAdmin")
            {
                var flight = _context.Flights.Where(x => x.Id == id).ToList().First();
                _context.Flights.Remove(flight);
                _context.Entry(flight).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
                await _context.SaveChangesAsync();

                return(Ok(new { message = "Successfully Delleted" }));
            }
            else
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> AddingAdmin(AddAdmin userModel)
        {
            string role = User.Claims.ElementAt(1).Value;

            if (role != UserRole.SystemAdmin.ToString())
            {
                return(BadRequest(new { message = "Bad data" }));
            }
            var applicationUser = new User()
            {
                UserName    = userModel.AdminUsername,
                Email       = userModel.Email,
                Name        = "",
                Surname     = "",
                PhoneNumber = "",
                Address     = userModel.Address,
            };

            //if (userModel.TypeOfCompany == "airline")
            //{
            //    Airline air = new Airline();
            //    air.Adress = userModel.Address;
            //    air.Description = userModel.Description;
            //    air.CompanyName = userModel.CompanyName;
            //    applicationUser.Role = UserRole.AirlineAdmin;

            //    try
            //    {
            //        var result = await _userManager.CreateAsync(applicationUser, userModel.Email);
            //        var kk1 = await _userManager.FindByEmailAsync(userModel.Email);
            //        kk1.AirlineComnpany = air;

            //        _context.Entry(kk1).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            //        await _context.SaveChangesAsync();
            //        return Ok(new { message = "Succesfuly added ! " });
            //    }
            //    catch (Exception ex)
            //    {
            //        return BadRequest(new { Message = "Invalid Data" });
            //        throw ex;

            //    }
            //}
            //else
            //{
            RentCarCompany carC = new RentCarCompany();

            carC.Adress          = userModel.Address;
            carC.Description     = userModel.Description;
            carC.CompanyName     = userModel.CompanyName;
            applicationUser.Role = UserRole.CarAdmin;

            try
            {
                var result = await _userManager.CreateAsync(applicationUser, userModel.Email);

                var kk1 = await _userManager.FindByEmailAsync(userModel.Email);

                kk1.CarCompany = carC;

                _context.Entry(kk1).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                await _context.SaveChangesAsync();

                return(Ok(new { message = "Succesfuly added ! " }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { Message = "Invalid Data" }));

                throw ex;
            }
            //}
        }
Пример #16
0
        public async Task <IActionResult> AddingCar(Car carModel)
        {
            string userID = User.Claims.ElementAt(0).Value;
            var    newCar = new Car()
            {
                BabySeats     = carModel.BabySeats,
                Location      = carModel.Location,
                NumberOfSeats = carModel.NumberOfSeats,
                Year          = carModel.Year,
                Model         = carModel.Model,
                PricePerDay   = carModel.PricePerDay,
                Brand         = carModel.Brand
            };

            if (newCar.PricePerDay <= 0 || newCar.Year <= 0 || newCar.NumberOfSeats <= 0 || newCar.BabySeats < 0)
            {
                return(BadRequest(new { message = "Invalid data! All field have to be possitive numbers!" }));
            }
            var user    = _context.Users.Include(x => x.CarCompany).Where(x => x.Id == userID).ToList().First();
            var company = _context.RentCarCompanies.Include(x => x.Cars).Where(x => x.Id == user.CarCompany.Id).ToList().First();

            company.Cars.Add(newCar);

            _context.Entry(company).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            await _context.SaveChangesAsync();


            return(Ok(new { message = "Succesfuly added ! " }));
        }