public bool Insert(ProductionLine productionLine)
 {
     _context.ProductionLine.Add(productionLine);
     _context.SaveChanges();
     //_context.Entry(machineType).Reference(name => machineType.Name).Load();
     return(true);
 }
 public bool Insert(Operations operations)
 {
     _context.Operations.Add(operations);
     _context.SaveChanges();
     return(true);
     //_context.Entry(operations).Reference(name => machineType.Name).Load();
 }
        public bootstrap(MasterContext context)
        {
            _context = context;


            if (_context.Operations.Count() == 0)
            {
                OperationsMDP op  = new OperationsMDP("desc1", "name1", 10, 1);
                OperationsMDP op2 = new OperationsMDP("desc2", "name2", 150, 2);
                _context.Operations.Add(op);
                _context.Operations.Add(op2);
                _context.SaveChanges();
            }
            if (_context.ManufacturingPlans.Count() == 0)
            {
                List <OperationsMDP> lista1 = new List <OperationsMDP>();
                List <OperationsMDP> lista2 = new List <OperationsMDP>();
                lista1.Add(_context.Operations.Find(1));
                lista2.Add(_context.Operations.Find(2));
                _context.ManufacturingPlans.Add(new ManufacturingPlan(DateTime.Today, lista1));
                _context.ManufacturingPlans.Add(new ManufacturingPlan(DateTime.Today, lista2));
                _context.SaveChanges();
            }

            if (_context.Products.Count() == 0)
            {
                _context.Products.Add(new Product(new Name("Product1"), _context.ManufacturingPlans.Find(1)));
                _context.Products.Add(new Product(new Name("Product2"), _context.ManufacturingPlans.Find(2)));
                _context.SaveChanges();
            }
        }
 public bool Insert(MachineType machineType)
 {
     _context.MachineType.Add(machineType);
     _context.SaveChanges();
     return(true);
     //_context.Entry(machineType).Reference(name => machineType.Name).Load();
 }
Beispiel #5
0
        public void Delete(int id)
        {
            var item = _context.Masters.First(x => x.Id == id);

            _context.Masters.Remove(item);
            _context.SaveChanges();
        }
        public IActionResult AddCustomer(string Customer_Name)
        {
            List <string> errors = new List <string>();

            if (Customer_Name != null)
            {
                Customer checkForCustomer = _context.Customer.SingleOrDefault(customer => customer.Customer_Name == Customer_Name);
                if (checkForCustomer == null)
                {
                    Customer newCutomer = new Customer
                    {
                        Customer_Name = Customer_Name,
                    };
                    _context.Add(newCutomer);
                    _context.SaveChanges();
                    return(RedirectToAction("Customers"));
                }
                errors.Add("Customer already exists.");
            }
            else
            {
                errors.Add("You need to enter a customers name.");
            }
            TempData["Errors"] = errors;
            return(RedirectToAction("Customers"));
        }
        public IActionResult CreateWedding(WeddingViewModel model)
        {
            if (ModelState.IsValid)
            {
                Wedding newWedding = new Wedding
                {
                    Groom_Name   = model.Groom_Name,
                    Bride_Name   = model.Bride_Name,
                    Wedding_Date = model.Wedding_Date,
                    user_id      = (int)HttpContext.Session.GetInt32("CurrUserId"),
                    created_at   = DateTime.Now,
                    updated_at   = DateTime.Now
                };
                _context.Wedding.Add(newWedding);
                _context.SaveChanges();
                return(RedirectToAction("weddingPage"));
            }
            List <string> errors = ModelState.Select(x => x.Value.Errors)
                                   .Where(y => y.Count > 0)
                                   .Select(z => z[0].ErrorMessage.ToString())
                                   .ToList();

            TempData["error_list"] = errors;
            return(RedirectToAction("weddingPage"));
        }
 public TEntity Insert(TEntity entity)
 {
     //entitatea poate sa fie nula sau poate sa fie formatata gresit
     dbSet.Add(entity);
     _context.SaveChanges(); //sys errors
     //string =! entity
     return(entity);
 }
Beispiel #9
0
 public bool Insert(OperationsMDP op)
 {
     if (op != null)
     {
         _context.Operations.Add(op);
         _context.SaveChanges();
     }
     return(true);
 }
Beispiel #10
0
 public static void AddPlantsDetails()
 {
     using (var db = new MasterContext())
     {
         var plant = new Plants();
         {
             Console.WriteLine("Enter PlantName!!");
             plant.PlantName = Console.ReadLine();
             Console.WriteLine("Enter PlantLocation!!");
             plant.PlantLocation = Console.ReadLine();
             Console.WriteLine("Enter CompanyId!!");
             plant.CompanyId = Convert.ToInt32(Console.ReadLine());
             var check = db.Plants.Where(t => t.PlantName == plant.PlantName);
             if (check != null)
             {
                 Console.WriteLine("Plant Name is Existing");
             }
             else
             {
                 db.Plants.Add(plant);
                 db.SaveChanges();
                 Console.WriteLine("Plants Information is added Successfully!!");
             }
         }
     }
 }
 protected void bttnSign_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         try
         {
             using (MasterContext context = new MasterContext())
             {
                 Hasta yeniKayit = new Hasta();
                 yeniKayit.Isim    = txtBoxName.Text;
                 yeniKayit.Soyisim = txtBoxSurrname.Text;
                 yeniKayit.TckNo   = txtBoxTckNo.Text;
                 yeniKayit.Adres   = txtBoxAdress.Text;
                 yeniKayit.Telefon = txtBoxPhoneNum.Text;
                 yeniKayit.Mail    = txtBoxMail.Text;
                 yeniKayit.Sifre   = txtBoxUserPass.Text;
                 context.Hasta.Add(yeniKayit);
                 context.SaveChanges();
             }
             Response.Redirect("Anasayfa.aspx");
         }
         catch
         {
             Response.Write("Kayıt başarısız!");
         }
     }
 }
        public static void AddProjectInfo()
        {
            using (var db = new MasterContext())
            {
                var project = new ProjectList();
                {
                    Console.WriteLine("Enter Project Title");
                    project.ProjectTitle = Console.ReadLine();

                    Console.WriteLine("Enter Project Definition");
                    project.ProjectDefinition = Console.ReadLine();


                    var check = db.ProjectList.Where(t => t.ProjectTitle == project.ProjectTitle);
                    if (check != null)
                    {
                        Console.WriteLine("This Project Info is Existing!!");
                    }
                    else
                    {
                        db.ProjectList.Add(project);
                        db.SaveChanges();
                        Console.WriteLine("Project Information is Successfully added!!");
                    }
                }
            }
        }
Beispiel #13
0
        public void chageDate(int artistID, int EventID, DateTime data)
        {
            var ArtistTMP = _contx.Artist.Where(e => e.IdArtist == artistID).FirstOrDefault();

            if (ArtistTMP == null)
            {
                throw new Exc_SthMissing("Artist with this ID is not existing");
            }

            var EventTMP = _contx.Event.Where(e => e.IdEvent == EventID).FirstOrDefault();

            if (EventTMP == null)
            {
                throw new Exc_SthMissing("Event with this ID is not existing");
            }
            Console.WriteLine(EventTMP.Name + " " + data);
            if (EventTMP.StartDate >= data && EventTMP.EndDate <= data)
            {
                throw new Exc_BadRequest("Date is not fitting the schedule xD");
            }

            var Res = _contx.ArtistEvent.Where(e => e.IdArtist == artistID && e.IdEvent == EventID).FirstOrDefault();

            Res.PerformanceDate = data;
            _contx.SaveChanges();
        }
Beispiel #14
0
 public static void AddToysDetails()
 {
     using (var db = new MasterContext())
     {
         var toy = new Toys();
         {
             Console.WriteLine("Enter ToyName!!");
             toy.ToyName = Console.ReadLine();
             Console.WriteLine("Enter ToyDescription!!");
             toy.ToyDescription = Console.ReadLine();
             Console.WriteLine("Enter ToyPrice!!");
             toy.ToyPrice = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine("Enter ToyBrand!!");
             toy.ToyBrand = Console.ReadLine();
             Console.WriteLine("Enter ToysCategoryId!!");
             toy.ToysCategoryId = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine("Enter PlantsId!!");
             toy.PlantId = Convert.ToInt32(Console.ReadLine());
             var check = db.Toys.Where(t => t.ToyName == toy.ToyName);
             if (check != null)
             {
                 Console.WriteLine("Toy Name is Existing");
             }
             else
             {
                 db.Toys.Add(toy);
                 db.SaveChanges();
                 Console.WriteLine("Toys Information is added Successfully!!");
             }
         }
     }
 }
Beispiel #15
0
        public IActionResult Register(RegistrationViewModel model, User newUser)
        {
            List <string> errors = new List <string>();

            if (ModelState.IsValid)
            {
                List <User>           allUsers = _context.User.Where(users => users.Email == model.Email).ToList();
                PasswordHasher <User> Hasher   = new PasswordHasher <User>();

                if (allUsers.Count < 1)
                {
                    newUser.Password = Hasher.HashPassword(newUser, newUser.Password);
                    _context.User.Add(newUser);
                    _context.SaveChanges();

                    User currentUser = _context.User.SingleOrDefault(user => user.Email == model.Email);
                    HttpContext.Session.SetInt32("CurrUserId", (int)currentUser.id);
                    return(RedirectToAction("Index", "New"));
                }
                else
                {
                    errors.Add("Email already exists in the Database.");
                }
            }
            else
            {
                errors = ModelState.Select(x => x.Value.Errors)
                         .Where(y => y.Count > 0)
                         .Select(z => z[0].ErrorMessage.ToString())
                         .ToList();
            }
            TempData["error_list"] = errors;
            return(RedirectToAction("Index"));
        }
Beispiel #16
0
        public ActionResult DynamicAddOrEdit(owl_DynamicPage model)
        {
            try
            {
                if (model.Id == 0)
                {
                    MasterContext dynamicadd = new MasterContext();

                    owl_DynamicPage dynamicPages = new owl_DynamicPage()
                    {
                        Name = model.Name,
                        Info = model.Info,
                    };

                    dynamicadd.DynamicPage.Add(dynamicPages);
                    dynamicadd.SaveChanges();
                    ViewBag.message = "Dynamic Sayfa Eklendi";
                    ModelState.Clear();
                    return(Redirect("/Dynamic/DynamicList"));
                }
                else
                {
                    MasterContext synamicadd = new MasterContext();

                    synamicadd.Entry(model).State = System.Data.Entity.EntityState.Modified;
                    synamicadd.SaveChanges();

                    return(Redirect("/Dynamic/DynamicList"));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #17
0
 public static void AddCompanyDetails()
 {
     using (var db = new MasterContext())
     {
         var company = new Companies();
         {
             Console.WriteLine("Enter CompanyName!!");
             company.CompanyName = Console.ReadLine();
             Console.WriteLine("Enter CompanyLocation!!");
             company.CompanyLocation = Console.ReadLine();
             Console.WriteLine("Enter CompanyEmailId!!");
             company.CompanyEmailId = Console.ReadLine();
             var check = db.Companies.Where(t => t.CompanyName == company.CompanyName);
             if (check != null)
             {
                 Console.WriteLine("Company Name is Existing");
             }
             else
             {
                 db.Companies.Add(company);
                 db.SaveChanges();
                 Console.WriteLine("Company Information is added Successfully!!");
             }
         }
     }
 }
 protected void bttnSign_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         try
         {
             using (MasterContext context = new MasterContext())
             {
                 Models.EFCore.Hekim yeniKayit = new Models.EFCore.Hekim();
                 yeniKayit.Isim         = txtBoxName.Text;
                 yeniKayit.Soyisim      = txtBoxSurrname.Text;
                 yeniKayit.TckNo        = txtBoxTckNo.Text;
                 yeniKayit.Adres        = txtBoxAdress.Text;
                 yeniKayit.Telefon      = txtBoxPhoneNum.Text;
                 yeniKayit.Mail         = txtBoxMail.Text;
                 yeniKayit.Sifre        = txtBoxUserPass.Text;
                 yeniKayit.PolikinlikId = Convert.ToInt32(polikinlikDDL.SelectedValue);
                 context.Hekim.Add(yeniKayit);
                 context.SaveChanges();
             }
             Response.Redirect("Goruntule.aspx");
         }
         catch
         {
             Response.Write("Kayıt başarısız!");
         }
     }
 }
        public void DeleteCollege(int id)
        {
            AddToKeylessTable.DeleteFromTable_Departments(id);

            _context.Colleges.Remove(_context.Colleges.SingleOrDefault(c => c.IdCollege == id));

            _context.SaveChanges();
        }
Beispiel #20
0
 public void DeleteClient(Punct4 punct)
 {
     using (var context = new MasterContext())
     {
         context.Entry(punct).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Beispiel #21
0
 public void Update(Punct4 punct)
 {
     using (var context = new MasterContext())
     {
         context.Entry(punct).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Beispiel #22
0
 public void AddPunct4(Punct4 punct)
 {
     using (var context = new MasterContext())
     {
         context.Set <Punct4>().Add(punct);
         context.SaveChanges();
     }
 }
Beispiel #23
0
 public void AddClient(Client client)
 {
     using (var context = new MasterContext())
     {
         context.Set <Client>().Add(client);
         context.SaveChanges();
     }
 }
Beispiel #24
0
 public void AddProduct(Product product)
 {
     using (var context = new MasterContext())
     {
         context.Set <Product>().Add(product);
         context.SaveChanges();
     }
 }
Beispiel #25
0
 public IActionResult Update(UserModel model)
 {
     using (MasterContext context = new MasterContext())
     {
         context.UserModels.Update(model);
         context.SaveChanges();
     }
     return(RedirectToAction("UserDetails"));
 }
Beispiel #26
0
        public IActionResult JobsApplied(Models.JobsApplied model)
        {
            var jerbId = 0;

            //Add New Jerb to Database if it doesnt exist
            var newJerbQuery = _db.JobsApplied.FirstOrDefault(x => x.Company == model.Company && x.Position == model.Position);

            if (newJerbQuery != null)
            {
                jerbId = newJerbQuery.Id;
            }
            else
            {
                var addNewJerb = new Models.JobsApplied
                {
                    Company     = model.Company,
                    DateApplied = model.DateApplied,
                    Interview   = model.Interview,
                    Position    = model.Position
                };

                _db.JobsApplied.Add(addNewJerb);
                _db.SaveChanges();
            }


            var userJobQuery =
                _db.UserJobs.FirstOrDefault(o => o.Email == _userManager.GetUserName(User) && o.JobId == jerbId);

            if (userJobQuery != null)
            {
                return(View());
            }
            var addUserJerb = new UserJobs
            {
                Email = _userManager.GetUserName(User),
                JobId = jerbId
            };

            _db.UserJobs.Add(addUserJerb);
            _db.SaveChanges();

            return(View());
        }
Beispiel #27
0
        public ActionResult NewsDelete(int id = 0)
        {
            MasterContext dbContext = new MasterContext();

            var DeleteVal = dbContext.News.Where(q => q.Id == id).FirstOrDefault();

            dbContext.News.Remove(DeleteVal);
            dbContext.SaveChanges();
            return(Redirect("/Media/NewsList"));
        }
Beispiel #28
0
        //Kullanıcı Tabolusunda Kullanıcıyı Silen Methot
        public IActionResult Delete(int id)
        {
            using (MasterContext context = new MasterContext())
            {
                context.UserModels.Remove(context.UserModels.Find(id));
                context.SaveChanges();

                return(RedirectToAction("UserDetails"));
            }
        }
Beispiel #29
0
 public IActionResult RegisterUser(RegisterViewModel model)
 {
     model.Password = Md5Helper.Instance.GetMd5Hash(model.Password);
     using (MasterContext context = new MasterContext())
     {
         context.UserModels.Add(model);
         context.SaveChanges();
     }
     return(RedirectToAction("Login"));
 }
        public ActionResult Product_Group_Delete(int id = 0)
        {
            MasterContext dbContext = new MasterContext();

            var DeleteVal = dbContext.Product_Gruop.Where(q => q.Id == id).FirstOrDefault();

            dbContext.Product_Gruop.Remove(DeleteVal);
            dbContext.SaveChanges();
            return(Redirect("/Product/Product_Group_List"));
        }