public ActionResult Save(Departmant departmant) { if (!ModelState.IsValid) { return(View("DepartmantForm", departmant)); } MessageViewModel message = new MessageViewModel(); using (PersonelDbContext db = new PersonelDbContext()) { if (departmant.Id == 0) { db.Departmants.Add(departmant); message.Message = $"{departmant.Name} başarıyla eklendi."; } else { var updatedDepartmant = db.Departmants.Find(departmant.Id); updatedDepartmant.Name = departmant.Name; message.Message = $"{departmant.Name} başarıyla güncellendi."; } db.SaveChanges(); message.Status = true; message.LinkText = "Departman Listesi"; message.Url = "/Departmant"; } return(PartialView("_Message", message)); //return RedirectToAction("Index", "Departmant"); }
public IHttpActionResult PostLogin([FromBody] Login login) { TitleManager titleManager = new TitleManager(); DepartmantManager departmantManager = new DepartmantManager(); ProjectManager projectManager = new ProjectManager(); ProcessManager processManager = new ProcessManager(); ContentManager contentManager = new ContentManager(); CustomerManager customerManager = new CustomerManager(); Employee employee = employeeManager.Find(e => e.email == login.email && e.password == login.password); if (employee != null) { Title title = titleManager.Find(x => x.ID == employee.TitleID); employee.Title = title; Departmant departmant = departmantManager.Find(x => x.ID == employee.DepartmantID); employee.Departmant = departmant; List <Process> processes = processManager.List(x => x.EmployeeID == employee.ID); foreach (Process item in processes) { Project project = projectManager.Find(x => x.ID == item.ProjectID); Customer customer = customerManager.Find(c => c.ID == project.CustomerID); project.Customer = customer; item.Project = project; List <Content> contents = contentManager.List(x => x.ProcessID == item.ID); item.Contents = contents; } employee.Processes = processes; return(Ok(employee)); } return(NotFound()); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Departmant departmant) { if (id != departmant.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(departmant); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmantExists(departmant.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(departmant)); }
public ActionResult DeleteConfirmed(int id) { Departmant departmant = db.Departmants.Find(id); db.Departmants.Remove(departmant); db.SaveChanges(); return(RedirectToAction("Index")); }
public IHttpActionResult GetProject(int id) { Departmant _object = manager.Find(x => x.ID == id); if (_object != null) { return(Ok(_object)); } return(NotFound()); }
public IActionResult Edit(int?id, [Bind("Id, Name")] Departmant departmant) { if (id == null || id != departmant.Id) { return(NotFound()); } _departmantService.Update(departmant); return(RedirectToAction("Index", "Departmans")); }
public async Task <IActionResult> Create([Bind("Id,Name")] Departmant departmant) { if (ModelState.IsValid) { _context.Add(departmant); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(departmant)); }
public IHttpActionResult PostProject(Departmant _object) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } manager.Insert(_object); return(CreatedAtRoute("DefaultApi", new { id = _object.ID }, _object)); }
public ActionResult Edit([Bind(Include = "ID,Name")] Departmant departmant) { if (ModelState.IsValid) { db.Entry(departmant).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.Departmants, "ID", "Name", departmant.ID); ViewBag.ID = new SelectList(db.Departmants, "ID", "Name", departmant.ID); return(View(departmant)); }
public ActionResult Create([Bind(Include = "ID,Name")] Departmant departmant) { if (ModelState.IsValid) { db.Departmants.Add(departmant); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ID = new SelectList(db.Departmants, "ID", "Name", departmant.ID); ViewBag.ID = new SelectList(db.Departmants, "ID", "Name", departmant.ID); return(View(departmant)); }
// GET: Departmants/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Departmant departmants = db.Departmants.Find(id); if (departmants == null) { return(HttpNotFound()); } return(View(departmants)); }
// GET: Departmants/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Departmant departmant = db.Departmants.Find(id); if (departmant == null) { return(HttpNotFound()); } ViewBag.ID = new SelectList(db.Departmants, "ID", "Name", departmant.ID); ViewBag.ID = new SelectList(db.Departmants, "ID", "Name", departmant.ID); return(View(departmant)); }
public IHttpActionResult PutProject(Departmant _object) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Departmant departmant2 = manager.Find(x => x.ID == _object.ID); if (departmant2 != null) { departmant2.name = _object.name; departmant2.description = _object.description; manager.Update(_object); return(Ok()); } return(BadRequest()); }
public IActionResult AddDepartmant([Bind("Name")] Departmant departmant) { if (ModelState.IsValid) { try { _departmantService.Add(departmant); return(RedirectToAction("Index", "Departmans")); } catch (Exception e) { throw; } } return(RedirectToAction("Index", "Departmans")); }
public ActionResult Save(Departmant departmant) { if (!ModelState.IsValid) { return(View("DepartmantForm", departmant)); } using (PersonelDbContext db = new PersonelDbContext()) { if (departmant.Id == 0) { db.Departmants.Add(departmant); } else { var updatedDepartmant = db.Departmants.Find(departmant.Id); updatedDepartmant.Name = departmant.Name; } db.SaveChanges(); } return(RedirectToAction("Index", "Departmant")); }
protected override void Seed(DatabaseContext context) { Random random = new Random(); //Adding authoritys.. for (int i = 0; i < 3; i++) { Departmant departmant = new Departmant() { name = FakeData.NameData.GetCompanyName(), description = FakeData.TextData.GetAlphabetical(10), }; context.Departmants.Add(departmant); } for (int i = 0; i < 3; i++) { Title title = new Title() { name = "standart", description = FakeData.TextData.GetAlphabetical(10), }; context.Titles.Add(title); } context.SaveChanges(); // Adding admin user.. Employee admin = new Employee() { name = "Abullah", surname = "Cangul", email = "*****@*****.**", activateGuid = Guid.NewGuid(), isActive = true, profileImageFilename = "user_boy.png", password = "******", createdAt = DateTime.Now, updatedAt = DateTime.Now.AddMinutes(5), updatedBy = "erdi yalçın", createdBy = "erdem siyam", Departmant = context.Departmants.ToList()[1], Title = context.Titles.ToList()[1] }; // Adding standart user.. Employee standartUser = new Employee() { name = "Hamza", surname = "Taş", email = "*****@*****.**", activateGuid = Guid.NewGuid(), isActive = true, profileImageFilename = "user_boy.png", password = "******", createdAt = DateTime.Now, updatedAt = DateTime.Now.AddMinutes(5), updatedBy = "erdem siyam", createdBy = "erdem siyam", Departmant = context.Departmants.ToList()[2], Title = context.Titles.ToList()[2] }; context.Employees.Add(admin); context.Employees.Add(standartUser); //adding 8 user for (int i = 0; i < 8; i++) { Employee user = new Employee() { name = FakeData.NameData.GetFirstName(), surname = FakeData.NameData.GetSurname(), email = FakeData.NetworkData.GetEmail(), profileImageFilename = "user_boy.png", activateGuid = Guid.NewGuid(), isActive = true, password = "******", createdAt = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), updatedAt = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), createdBy = $"user{i}", Departmant = context.Departmants.ToList()[random.Next(1, 3)], Title = context.Titles.ToList()[random.Next(1, 3)] }; context.Employees.Add(user); } context.SaveChanges(); //adding Customer for (int i = 0; i < 3; i++) { Customer customer = new Customer() { name = FakeData.NameData.GetFirstName(), email = FakeData.NetworkData.GetEmail(), competnent = "süper", description = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(5, 7)), url = FakeData.NetworkData.GetDomain(), password = "******", Employee = context.Employees.ToList()[i], }; context.Customers.Add(customer); } Customer customerStandart = new Customer() { competnent = "hiper", description = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(5, 5)), url = FakeData.NetworkData.GetDomain(), email = FakeData.NetworkData.GetEmail(), password = "******", Employee = context.Employees.SingleOrDefault(x => x.email == "*****@*****.**"), }; context.Customers.Add(customerStandart); context.SaveChanges(); for (int i = 0; i < 3; i++) { Project project = new Project() { Customer = context.Customers.ToList()[i], Employee = context.Employees.ToList()[i], description = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(5, 7)), name = FakeData.NameData.GetFirstName(), }; context.Projects.Add(project); } context.SaveChanges(); for (int i = 0; i < 2; i++) { Content content = new Content() { message = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 3)), isCustomer = true, //Process = context.Processes.ToList()[i], }; context.Contents.Add(content); } context.SaveChanges(); for (int i = 0; i < 2; i++) { Process process = new Process() { Employee = context.Employees.ToList()[i + 1], Project = context.Projects.ToList()[i + 1], Contents = context.Contents.ToList(), priority = "kırmızı", status = "ilerliyor", }; context.Processes.Add(process); } context.SaveChanges(); // base.Seed(context); }
public void Add(Departmant departmant) { _departmantDal.Add(departmant); }
public void Update(Departmant departmant) { _departmantDal.Update(departmant); }