public ActionResult Create([Bind(Include = "Prezime,Ime,DatumZaposlenja,Email")] Lekar lekar, HttpPostedFileBase upload) //Sklonjen ID - auto.. { try { if (ModelState.IsValid) { if (upload != null && upload.ContentLength > 0)// { var foto = new File { FileName = System.IO.Path.GetFileName(upload.FileName), FileType = FileType.Foto, ContentType = upload.ContentType }; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { foto.Content = reader.ReadBytes(upload.ContentLength); } lekar.Files = new List <File> { foto }; } db.Lekari.Add(lekar); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(lekar)); }
public ActionResult Create([Bind(Include = "Prezime,Ime,DatumRegistracije,Firma")] Pacijent pacijent, HttpPostedFileBase upload) //Sklonjen ID - automatski se unosi.. Dodata param. upload.. { try { if (ModelState.IsValid) { if (upload != null && upload.ContentLength > 0) //ContentLenght provera da nije empty file { var dokument = new File { FileName = System.IO.Path.GetFileName(upload.FileName), FileType = FileType.Dokument, ContentType = upload.ContentType }; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { dokument.Content = reader.ReadBytes(upload.ContentLength); } pacijent.Files = new List <File> { dokument }; //Dodaje u Files kolekciju u pac. } db.Pacijenti.Add(pacijent); db.SaveChanges(); return(RedirectToAction("Index")); } } catch (DataException) { ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View(pacijent)); }
public static void AddNotification(mp_notification notification) { notification.title = ConstructTitle(notification.notification_type); notification.notification = ConstructMessage(notification.notification_type); notification.created_at = DateTime.Now; _context.mp_notification.Add(notification); _context.SaveChanges(); }
public long AddPrescription(mp_prescription prescription) { prescription.created_at = DateTime.Now; _context.mp_prescription.Add(prescription); _context.SaveChanges(); return(prescription.id); }
public void AddApplicantPopulationGroup(List <mp_applicant_population> populations) { foreach (var population in populations) { _context.mp_applicant_population.Add(population); } _context.SaveChanges(); }
public long AddPlan(mp_mental_health_plan plan) { plan.created_at = DateTime.Now; _context.mp_mental_health_plan.Add(plan); _context.SaveChanges(); return(plan.id); }
public void AddApplicantSpecialty(List <mp_applicant_specialty> specialties) { foreach (var specialty in specialties) { _context.mp_applicant_specialty.Add(specialty); } _context.SaveChanges(); }
public Guid AddClinic(mp_clinic clinic) { clinic.id = Guid.NewGuid(); clinic.created_at = DateTime.Now; _context.mp_clinic.Add(clinic); _context.SaveChanges(); return(clinic.id); }
public void AddApplicantPractice(List <mp_applicant_practice> practices) { foreach (var practice in practices) { _context.mp_applicant_practice.Add(practice); } _context.SaveChanges(); }
public void AddApplicantExpertise(List <mp_applicant_expertise> expertises) { foreach (var exp in expertises) { // _context.mp_applicant_expertise.Add(exp); } _context.SaveChanges(); }
public void AddApplicantActivities(List <mp_applicant_other_activities> other_Activities) { foreach (var activity in other_Activities) { _context.mp_applicant_other_activities.Add(activity); } _context.SaveChanges(); }
public Guid Add(mp_applicant profile) { profile.id = Guid.NewGuid(); profile.created_at = DateTime.Now; _context.mp_applicant.Add(profile); _context.SaveChanges(); return(profile.id); }
public void AddApplicantLanguage(List <mp_applicant_language> languages) { foreach (var language in languages) { _context.mp_applicant_language.Add(language); } _context.SaveChanges(); }
public Guid Add(mp_appointment appointment) { appointment.id = Guid.NewGuid(); appointment.created_by = "Self"; appointment.created_at = DateTime.Now; _context.mp_appointment.Add(appointment); _context.SaveChanges(); return(appointment.id); }
public void AddApplicantEducation(List <mp_applicant_education> educations) { foreach (var education in educations) { education.created_at = DateTime.Now; _context.mp_applicant_education.Add(education); } _context.SaveChanges(); }
public ActionResult Create([Bind(Include = "PregledID,Naziv,Opis")] Pregled pregled) { if (ModelState.IsValid) { db.Pregledi.Add(pregled); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pregled)); }
public int Update(mp_psychiatric_progress_note progess_note) { var existing = _context.mp_psychiatric_progress_note.FirstOrDefault(m => m.id == progess_note.id); if (existing != null) { //do update progess_note.created_at = existing.created_at; progess_note.created_by = existing.created_by; _context.Entry(existing).CurrentValues.SetValues(progess_note); return(_context.SaveChanges()); } return(0); }
public UserModel ModifyPassword(UserModel user) { try { using (HContext dbContext = new HContext()) { if (user.Id > 0) { UserModel model = dbContext.Users.Find(user.Id); if (model != null) { model.Password = user.Password; dbContext.SaveChanges(); return(user); } } user.ErrorCode = -2; user.ErrorMsg = "没有找到该用户"; return(user); } } catch (Exception ex) { user.ErrorCode = -1; user.ErrorMsg = ex.Message; return(user); } }
public bool UpdateUserCover(UserModel user) { using (HContext dbContext = new HContext()) { UserModel model = dbContext.Users.Where(a => a.Id == user.Id).FirstOrDefault(); model.Cover = user.Cover; return(dbContext.SaveChanges() > 0); } }
public int AddPediatricEvaluation(mp_pediatric_evaluation evaluation) { var old = _context.mp_pediatric_evaluation.FirstOrDefault(e => e.appointment_id == evaluation.appointment_id && e.profile_id == evaluation.profile_id); if (old == null) { _context.Add(evaluation); } else { evaluation.created_by = old.created_by; evaluation.created_date = old.created_date; evaluation.id = old.id; _context.Entry(old).CurrentValues.SetValues(evaluation); } _context.SaveChanges(); return(evaluation.id); }
public static void AddConversation(mp_conversation conversation) { try { conversation.created_at = DateTime.Now; _context.mp_conversation.Add(conversation); _context.SaveChanges(); } catch (Exception ex) { } }
public int UpdateLookUp(mp_lookup lookup) { var existing = _context.mp_lookup.FirstOrDefault(m => m.id == lookup.id); if (existing != null) { //do update lookup.deleted = 0; _context.Entry(existing).CurrentValues.SetValues(lookup); return _context.SaveChanges(); } return 0; }
public static mp_lookup AddLookup(mp_lookup lookup) { //get the maximum lookup var count = _context.mp_lookup.Count(); lookup.id = count + 1; lookup.deleted = 0; _context.mp_lookup.Add(lookup); _context.SaveChanges(); return(lookup); }
//updates mp_substance_use record //returns 0 if record was not found public int UpdateSubstanceUse(mp_substance_use substance_use) { var existing = _context.mp_substance_use.FirstOrDefault(m => m.id == substance_use.id); if (existing != null) { //do update substance_use.created_at = existing.created_at; substance_use.created_by = existing.created_by; _context.Entry(existing).CurrentValues.SetValues(substance_use); return(_context.SaveChanges()); } return(0); }
public int UpdateSocialRelationship(mp_social_relationship relationship) { var existing = _context.mp_social_relationship.FirstOrDefault(m => m.id == relationship.id); if (existing != null) { //do update relationship.created_at = existing.created_at; relationship.created_by = existing.created_by; _context.Entry(existing).CurrentValues.SetValues(relationship); return(_context.SaveChanges()); } return(0); }
public void AddOrUpdate(mp_clinician_availability availability) { if (_context.mp_clinician_availability.Any(e => e.clinician_id == availability.clinician_id && e.day_name == availability.day_name)) { // run update var old = _context.mp_clinician_availability.FirstOrDefault(e => e.clinician_id == availability.clinician_id && e.day_name == availability.day_name); availability.id = old.id; _context.Entry(old).CurrentValues.SetValues(availability); } else { _context.mp_clinician_availability.Add(availability); } _context.SaveChanges(); }
public bool DeleteUser(IList <UserModel> users) { using (HContext dbContext = new HContext()) { List <int> ids = new List <int>(); foreach (UserModel m in users) { ids.Add(m.Id); } IList <UserModel> models = dbContext.Users.Where(a => ids.Contains(a.Id)).ToList(); foreach (UserModel m in models) { m.Status = 1; } return(dbContext.SaveChanges() > 0); } }
public void AddOrUpdate(mp_clinician_rating rating) { var old = _context.mp_clinician_rating.FirstOrDefault(e => e.id == rating.id); if (old != null) { rating.created_at = old.created_at; rating.created_by = old.created_by; _context.Entry(old).CurrentValues.SetValues(rating); } else { rating.created_at = DateTime.Now; _context.mp_clinician_rating.Add(rating); } _context.SaveChanges(); }
public Guid Add(mp_profile_match profile_match) { //check if the match already exists var old = _context.mp_profile_match.FirstOrDefault(e => e.profile_id == profile_match.profile_id && e.clinician_id == profile_match.clinician_id && e.appointment_type_id == profile_match.appointment_type_id && e.appointment_activity_id == profile_match.appointment_activity_id && e.appointment_activity_sub_id == profile_match.appointment_activity_sub_id); if (old != null) { return(old.id); } profile_match.id = Guid.NewGuid(); profile_match.created_at = DateTime.Now; _context.mp_profile_match.Add(profile_match); _context.SaveChanges(); return(profile_match.id); }
public void AddOrUpdate(mp_profile_bank bank) { var old = _context.mp_profile_bank.FirstOrDefault(e => e.id == bank.id); if (old != null) { bank.created_at = old.created_at; bank.created_by = old.created_by; bank.updated_at = DateTime.Now; _context.Entry(old).CurrentValues.SetValues(bank); } else { bank.created_at = DateTime.Now; _context.mp_profile_bank.Add(bank); } _context.SaveChanges(); }