public IActionResult CreateUser(int familyId, [FromBody] User user) { if (user == null) { return(BadRequest()); } var family = _context.Families.FirstOrDefault(f => f.Id == familyId); if (family == null) { return(NotFound("The family specified doesn't exist")); } var finalUser = new User() { First = user.First, Last = user.Last, FamilyId = family.Id }; _context.Users.Add(finalUser); _context.SaveChanges(); return(Created("api/[Controller]/{familyId}/user", finalUser)); }
public void RecalculateGlobalNote(List <t_collaborator> list) { //get the list from database List <t_collaborator> TargetList = new List <t_collaborator>(); t_collaborator target; foreach (t_collaborator collab in list) { target = _context.t_collaborator.Where(c => c.C_ID == collab.C_ID).FirstOrDefault(); TargetList.Add(target); } //caluculate global Note foreach (t_collaborator c in TargetList) { float note360 = c.t_performancenote.ElementAt(0).global360Note; float noteAuto = c.t_performancenote.ElementAt(0).gloabalAutoNote; float AllNote = note360 * GlobalNoteCoefficients.GetCoeff360() + noteAuto * GlobalNoteCoefficients.GetCoeffAuto(); float globalNoteCaluculated = AllNote / GlobalNoteCoefficients.GetAllCoeff(); c.t_performancenote.ElementAt(0).globalPerformance = globalNoteCaluculated; _context.SaveChanges(); } //recalculate rank RecalculateRank(); }
public Warning AddWarning(Warning w) { Warning wa = _context.t_warning.Add(w); _context.SaveChanges(); return(wa); }
public ActionResult Create([Bind(Include = "Id,FirstName,lastName,birthDate,adress,ImageName,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName,Insuranceid")] Patient patient) { if (ModelState.IsValid) { db.Users.Add(patient); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(patient)); }
public ActionResult Create([Bind(Include = "StepId,treatment,state")] Step step) { if (ModelState.IsValid) { db.Steps.Add(step); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(step)); }
public ActionResult Create([Bind(Include = "AppointmentId,Date,Disease,state")] Appointment appointment) { if (ModelState.IsValid) { db.Appointments.Add(appointment); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(appointment)); }
public ActionResult Edit([Bind(Include = "Id,Email,PasswordHash,SecurityStamp,PhoneNumber, LockoutEndDateUtc,AccessFailedCount,UserName, FirstName,LastName,birthDate,adress,imageName,Speciality ")] Doctor d, HttpPostedFileBase Image) { //Doctor do= new Doctor(); // TODO: Add update logic here if (ModelState.IsValid) { String fileName = Path.GetFileName(Image.FileName); d.ImageName = fileName; var doctor = ds.GetMany().Single(em => em.Id == d.Id); d.PasswordHash = doctor.PasswordHash; d.SecurityStamp = doctor.SecurityStamp; db.Entry(d).State = EntityState.Modified; db.SaveChanges(); // ds.Update(d); // ds.Commit(); return(RedirectToAction("Index")); } // return RedirectToAction("Index"); return(View(d)); }
public void IncrementBadFeedbackCountForCollaborator(int idcollab) { t_collaborator c0 = _context.t_collaborator.Where(c1 => c1.C_ID == idcollab).FirstOrDefault(); c0.t_performancenote.ElementAt(0).NbreBadFeedbacks = c0.t_performancenote.ElementAt(0).NbreBadFeedbacks + 1; _context.SaveChanges(); }
public IActionResult CreateFamily(string name) { var familyExists = _context.Families.FirstOrDefault(f => f.Name == name); if (familyExists != null) { return(BadRequest("This family name already exists")); } var newFamily = new Family() { Name = name }; _context.Families.Add(newFamily); _context.SaveChanges(); return(Created("api/[controller]/{name}", newFamily)); }
static void Main(string[] args) { PiContext ctx = new PiContext(); Course c = new Course { }; /* Patient u = new Patient { Email = "*****@*****.**", * adress = "1 rue de sfax", * UserName="******", * PasswordHash="sameh", * lastName="Garouachi", * birthDate=DateTime.Now, * course=c }; * // ctx.Users.Add(u); * // ctx.SaveChanges(); * // c.steps * // SC.Add(c); * ctx.Courses.Add(c); * ctx.Users.Add(u);*/ List <Appointment> appointments = new List <Appointment>() { new Appointment { state = State.Done, Date = DateTime.Now }, new Appointment { state = State.Done, Date = DateTime.Now }, new Appointment { state = State.Done, Date = DateTime.Now }, new Appointment { state = State.Done, Date = DateTime.Now }, new Appointment { state = State.Done, Date = DateTime.Now }, new Appointment { state = State.Done, Date = DateTime.Now }, new Appointment { state = State.Done, Date = DateTime.Now }, new Appointment { state = State.Done, Date = DateTime.Now } }; ctx.Appointments.AddRange(appointments); ctx.SaveChanges(); }
public ActionResult Edit([Bind(Include = "AppointmentId,Date,Location,AppointmentState, Doctor,DoctorId,Patient, PatientId")] Appointment ap) { if (ModelState.IsValid) { var appointment = SA.GetMany().Single(a => a.AppointmentId == ap.AppointmentId); ap.AppointmentState = appointment.AppointmentState; ap.Date = appointment.Date; ap.Location = ap.Location; ap.Doctor = ap.Doctor; pi.Entry(ap).State = EntityState.Modified; pi.SaveChanges(); return(RedirectToAction("Index")); } return(View(ap)); }
public void SaveSeries(Series cryptoSeries) { PiContext.Series.Add(cryptoSeries); PiContext.SaveChanges(); }
public ActionResult Save(int?id, FormCollection actionValues) { var action = new DataAction(actionValues); var medecin = sm.getDoctorByUserName(AccountController.UserCoUserName); try { var changedEvent = DHXEventsHelper.Bind <Disponibility>(actionValues); changedEvent.DoctorId = medecin.Single().Id; switch (action.Type) { case DataActionTypes.Insert: { if (changedEvent.StartDate >= DateTime.Now.Date) { changedEvent.Description = "Disponible"; db.Disponibilities.Add(changedEvent); } else { Response.Write("alert('You can t add disponibility in the past')"); } } break; case DataActionTypes.Delete: if (changedEvent.DoctorId == ((sm.getDoctorByUserName(AccountController.UserCoUserName)).Single()).Id) { db.Entry(changedEvent).State = EntityState.Deleted; } else { Response.Write("alert('You can t delete disponibility of another doctor')"); } break; default: // "update" { if (changedEvent.StartDate >= DateTime.Now.Date) { if (changedEvent.DoctorId == ((sm.getDoctorByUserName(AccountController.UserCoUserName)).Single()).Id) { db.Entry(changedEvent).State = EntityState.Modified; } else { Response.Write("alert('You can t update disponibility of another doctor')"); } } else { Response.Write("alert('You can t update disponibility in the past')"); } } break; } db.SaveChanges(); action.TargetId = changedEvent.Id; } catch (Exception a) { action.Type = DataActionTypes.Error; } return(new AjaxSaveResponse(action)); }
public void Commit() { dataContext.SaveChanges(); }