public ActionResult Create(conge h) { if (ModelState.IsValid) { a.addConge(h); return(RedirectToAction("IndexBack")); } else { return(View()); } }
// GET: Conge/Edit/5 public ActionResult Edit(int id) { conge cm = new conge(); cm = cs.Get(t => t.id == id); CongeModels c = new CongeModels(); c.DateDebut = cm.DateDebut; c.DateFin = cm.DateFin; c.certefica = cm.certefica; c.typeConge = cm.typeConge; return(View(c)); }
public ActionResult Edit(FormCollection formValues, int id) { IUnitOfWork Uok = new UnitOfWork(Factory); IService <conge> jbService = new Service <conge>(Uok); conge app = jbService.GetById(id); // TODO: Add update logic here app.date_deb = DateTime.Parse(Request.Form["date_deb"]); app.date_fin = DateTime.Parse(Request.Form["date_fin"]); app.etat = Request.Form["etat"]; jbService.Commit(); return(RedirectToAction("Index")); }
// GET: conges/Delete/5 public ActionResult Delete(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IUnitOfWork Uok = new UnitOfWork(Factory); IService <conge> jbService = new Service <conge>(Uok); conge conge = jbService.GetById(id); if (conge == null) { return(HttpNotFound()); } return(View(conge)); }
public ActionResult DetailsAdmin(int id) { conge cm = new conge(); CongeModels c = new CongeModels(); cm = cs.Get(t => t.id == id); c.DateDebut = cm.DateDebut; c.DateFin = cm.DateFin; c.certefica = cm.certefica; c.typeConge = cm.typeConge; ViewBag.id = cm.id; ViewBag.reponse = cm.reponse; ViewBag.nbr_jrs = cm.nbr_jr; return(View(c)); }
public ActionResult Create(CongeModels cm, HttpPostedFileBase file) { { if (!ModelState.IsValid || file == null || file.ContentLength == 0) { RedirectToAction("Create"); } } conge c = new conge(); c.id = cm.id; c.typeConge = cm.typeConge; if (c.typeConge == "Maladie") { c.certefica = file.FileName; var fileName = ""; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path. Combine(Server.MapPath("~/Content/Upload/"), fileName); file.SaveAs(path); } } else if (c.typeConge == "Normale") { c.certefica = "N'a pas besoin de certificat"; } c.DateDebut = cm.DateDebut; c.DateFin = cm.DateFin; c.reponse = "false"; c.typeConge = cm.typeConge; c.demandeConge = "true"; //c.certefica = cm.certefica; //calcule nbr jours conge // System.TimeSpan diff1 = c.DateFin.Subtract(DateTime.Now); // int x = (int)diff1.TotalDays; //c.nbr_jr = x; cs.Add(c); cs.Commit(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Create(conge t) { if (ModelState.IsValid) { HttpClient client = new HttpClient(); var json = JsonConvert.SerializeObject(t, Formatting.Indented, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() }); using (var stringContent = new StringContent(json, Encoding.UTF8, "application/json")) { var result = await client.PostAsync(new Uri("http://localhost:9080/pidev-web/rest/conge/"), stringContent); } } return(RedirectToAction("list")); }
public ActionResult Create(CongViewModels collection) { if (collection.congeDebut < DateTime.Now || collection.congeFin < DateTime.Now) { Response.Write("<script>alert('invalid date')</script>"); return(View()); } conge c = new conge(); c.idConge = collection.idConge; c.congeDebut = collection.congeDebut; c.congeFin = collection.congeFin; sc.Add(c); sc.Commit(); Response.Write("<script>alert('Your request has been sent')</script>"); return(View()); }
public ActionResult Edit(int id, CongeModels cm, HttpPostedFileBase file) { { if (!ModelState.IsValid || file == null || file.ContentLength == 0) { RedirectToAction("Create"); } } conge c = new conge(); c = cs.Get(t => t.id == id); c.id = cm.id; c.DateDebut = cm.DateDebut; c.DateFin = cm.DateFin; c.typeConge = cm.typeConge; if (c.typeConge == "Maladie") { c.certefica = file.FileName; var fileName = ""; if (file.ContentLength > 0) { fileName = Path.GetFileName(file.FileName); var path = Path. Combine(Server.MapPath("~/Content/Upload/"), fileName); file.SaveAs(path); } } else if (c.typeConge == "Normale") { c.certefica = "N'a pas besoin de certificat"; } cs.Update(c); cs.Commit(); return(RedirectToAction("Index")); }
public void deleteConge(conge p) { ut.CongeRepository.Delete(p); ut.commit(); }
public void addConge(conge p) { ut.CongeRepository.Add(p); ut.commit(); }
public ActionResult valider(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IUnitOfWork Uok = new UnitOfWork(Factory); IService <conge> jbService = new Service <conge>(Uok); IService <employe> jbServiceEmploye = new Service <employe>(Uok); conge app = jbService.GetById(id); employe e = jbServiceEmploye.GetById(app.employe_id.Value); DateTime fin = DateTime.Parse(app.date_fin.ToString()); DateTime deb = DateTime.Parse(app.date_deb.ToString()); TimeSpan Diff = fin - deb; int nb = int.Parse(Diff.Days.ToString()) + 1; // TODO: Add update logic here if (app == null) { return(HttpNotFound()); } else { if (e.nb_conge_restants - nb >= 0) { app.etat = "valide"; e.nb_conge_restants = e.nb_conge_restants - nb; jbServiceEmploye.Commit(); //envoyer mail var verifyurl = "/Signup/VerifiyAccount/"; var link = Request.Url.AbsolutePath.Replace(Request.Url.PathAndQuery, verifyurl); var fromEmail = new MailAddress("*****@*****.**", "lamloum manel"); var toEmail = new MailAddress(e.email); // var toEmail = new MailAddress("*****@*****.**"); var FromEmailPassword = "******"; string subject = "Validation du conge"; string body = "Nous vous informons de l'acceptation de votre demande de congé du " + app.date_deb + " jusqu'à " + app.date_fin; var smtp = new SmtpClient { Host = "smtp.gmail.com", Port = 587, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential(fromEmail.Address, FromEmailPassword), Timeout = 20000 }; using (var message = new MailMessage(fromEmail, toEmail) { Subject = subject, Body = body, IsBodyHtml = true }) smtp.Send(message); //envoyer mail } else { System.Windows.Forms.MessageBox.Show("Cet employe n'a que " + e.nb_conge_restants + " jours de congé restants cette année ! DEMANDE REFUSEE !"); this.refuser(app.id); } } return(RedirectToAction("list_demandes_manager")); }
public void RechercherConge(conge c, int id) { throw new NotImplementedException(); }
public void ModifierConge(conge c) { throw new NotImplementedException(); }
public void DeleteConge(conge c) { utwk.CongeRepository.Delete((c)); utwk.Commit(); }
public void AddConge(conge c) { utwk.CongeRepository.Add(c); utwk.Commit(); }