Beispiel #1
0
        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ı"));
        }
Beispiel #2
0
        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"));
        }
Beispiel #3
0
 public IActionResult Create(RoleModel model)
 {
     //  _db.Set<Roles>().Add(model.Roles);
     _db.Entry(model.Roles).State = EntityState.Added;
     // yyyy
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        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 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ı!"));
        }
Beispiel #6
0
 public ActionResult Sil(int?id)
 {
     using (PersonelContext ctx = new PersonelContext())
     {
         var per = ctx.Personeler.Find(id);
         ctx.Personeler.Remove(per);
         ctx.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Kayit(Kullanici klc)
 {
     if (ModelState.IsValid)
     {
         ctx.Kullanicilar.Add(klc);
         int sonuc = ctx.SaveChanges();
         if (sonuc > 0)
         {
             return(RedirectToAction("Login", "Giris"));
         }
     }
     return(View());
 }
Beispiel #8
0
 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());
     }
 }
Beispiel #9
0
 public ActionResult Ekle(Personel p)
 {
     if (ModelState.IsValid)
     {
         using (PersonelContext ctx = new PersonelContext())
         {
             ctx.Personeler.Add(p);
             int sonuc = ctx.SaveChanges();
             if (sonuc > 0)
             {
                 return(RedirectToAction("Index"));
             }
         }
     }
     return(RedirectToAction("Ekle"));
 }
Beispiel #10
0
        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ı"));
        }
Beispiel #11
0
        public IActionResult CategoryCreate([FromBody] NameModel model)
        {
            if (string.IsNullOrEmpty(model.name))
            {
                return(BadRequest("İsim Boş Bırakılamaz."));
            }
            Category category = new Category
            {
                Id           = new Guid(),
                CategoryName = model.name
            };

            _db.Add(category);
            _db.SaveChanges();

            return(Ok("Kayıt Başarılı"));
        }
        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ı"));
        }