public async Task <IActionResult> Edit(RoleModel model) { _db.Entry(model.Roles).State = EntityState.Modified; await _db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public IActionResult AddInventory([FromBody] InventoryListModel model) { var inv = _db.Set <Inventory>().FirstOrDefault(x => x.SeriNo == model.seriNo); if (inv != null) { if (inv.SeriNo == model.seriNo) { return(BadRequest("Bu Seri Numaraya Ait Ürün Bulunmaktadır. Lütfen Seri Numarayı Kontrol Edip Tekrar Deneyiniz.")); } } var inventory = new Inventory { Id = new Guid(), Marka = model.marka, Feature = model.feature, Name = model.name, Model = model.model, SeriNo = model.seriNo, Status = false, }; _db.Entry(inventory).State = Microsoft.EntityFrameworkCore.EntityState.Added; _db.SaveChanges(); return(Ok("Envanter Sisteme Eklendi")); }
public IActionResult Add([FromBody] usersDTO user) { if (string.IsNullOrEmpty(user.name)) { return(BadRequest("İsim Boş Bırakılamaz!")); } if (string.IsNullOrEmpty(user.surname)) { return(BadRequest("Soyisim Boş Bırakılamaz!")); } //Devam Edilebilir... Users users = new Users { Name = user.name, Surname = user.surname, CityId = user.cityId, ManagerId = user.managerId, Birthday = Convert.ToDateTime(user.birthday), Gender = user.gender, Department = user.department, DistrictId = user.districtId }; _db.Entry(users).State = Microsoft.EntityFrameworkCore.EntityState.Added; _db.SaveChanges(); return(Ok("Kayıt Başarılı!")); }
public IActionResult CreatePassword(Guid UserId, string Password, string ConfirmPassword) { //Admin Kullanıcının şifresini değiştirirse eski parolayı false yapmak için yazıldı. var password = _db.Set <UserPassword>().FirstOrDefault(x => x.UserId == UserId && x.ActivePassword); password.ActivePassword = false; //////////////////////////////// if (ModelState.IsValid) { var pass = new UserPassword { UserId = UserId, Password = Password, ConfirmPassword = ConfirmPassword, ActivePassword = true }; if (Password == ConfirmPassword) { _db.Entry(pass).State = Microsoft.EntityFrameworkCore.EntityState.Added; _db.SaveChanges(); return(Json(pass)); } return(BadRequest("Şifreler Eşleşmedi")); } return(BadRequest("Parola Oluşturulamadı")); }
public IActionResult CityAdd([FromBody] City city) { if (string.IsNullOrEmpty(city.Name)) { return(BadRequest("İsim Boş Bırakılamaz")); } //var c = new City //{ // Name = city.name, //}; _db.Entry(city).State = Microsoft.EntityFrameworkCore.EntityState.Added; _db.SaveChanges(); return(Ok("İl Ekleme Başarılı")); }
public ActionResult Duzenle(Personel per) { using (PersonelContext ctx = new PersonelContext()) { ctx.Entry(per).State = EntityState.Modified; int sonuc = ctx.SaveChanges(); if (sonuc > 0) { return(RedirectToAction("Index")); } return(View()); } }
public IActionResult ProductCreate([FromBody] ProductModel model) { if (model.file == null) { return(BadRequest("Dosya Bulunamadı")); } Products product = new Products { Id = new Guid(), ProductName = model.name, Size = model.size, Amount = model.amount, Price = model.price, Title = model.title, CategoryId = model.categoryid, }; _db.Entry(product).State = Microsoft.EntityFrameworkCore.EntityState.Added; _db.SaveChanges(); return(Json("Kayıt Başarılı")); }
public void Delete(T entity) { _db.Entry(entity).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; }
public IActionResult CreatePassword(Guid UserId, string Password, string ConfirmPassword) { if (ModelState.IsValid) { var pass = new UserPassword { UserId = UserId, Password = Password, ConfirmPassword = ConfirmPassword, ActivePassword = true }; if (Password == ConfirmPassword) { _db.Entry(pass).State = Microsoft.EntityFrameworkCore.EntityState.Added; _db.SaveChanges(); return(Json(pass)); } return(BadRequest("Şifreler Eşleşmedi")); } return(BadRequest("Parola Oluşturulamadı")); }
public void Add(T entity) { _db.Entry(entity).State = EntityState.Added; }
public void Delete(T entity) { _db.Entry(entity).State = EntityState.Deleted; }