コード例 #1
0
 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));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 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();
 }
コード例 #4
0
        public long AddPrescription(mp_prescription prescription)
        {
            prescription.created_at = DateTime.Now;
            _context.mp_prescription.Add(prescription);
            _context.SaveChanges();

            return(prescription.id);
        }
コード例 #5
0
 public void AddApplicantPopulationGroup(List <mp_applicant_population> populations)
 {
     foreach (var population in populations)
     {
         _context.mp_applicant_population.Add(population);
     }
     _context.SaveChanges();
 }
コード例 #6
0
        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);
        }
コード例 #7
0
 public void AddApplicantSpecialty(List <mp_applicant_specialty> specialties)
 {
     foreach (var specialty in specialties)
     {
         _context.mp_applicant_specialty.Add(specialty);
     }
     _context.SaveChanges();
 }
コード例 #8
0
        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);
        }
コード例 #9
0
        public void AddApplicantPractice(List <mp_applicant_practice> practices)
        {
            foreach (var practice in practices)
            {
                _context.mp_applicant_practice.Add(practice);
            }

            _context.SaveChanges();
        }
コード例 #10
0
        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();
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public void AddApplicantLanguage(List <mp_applicant_language> languages)
        {
            foreach (var language in languages)
            {
                _context.mp_applicant_language.Add(language);
            }

            _context.SaveChanges();
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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();
        }
コード例 #16
0
        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));
        }
コード例 #17
0
        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);
        }
コード例 #18
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);
     }
 }
コード例 #19
0
 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);
     }
 }
コード例 #20
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);
        }
コード例 #21
0
 public static void AddConversation(mp_conversation conversation)
 {
     try
     {
         conversation.created_at = DateTime.Now;
         _context.mp_conversation.Add(conversation);
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
     }
 }
コード例 #22
0
 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;
 }
コード例 #23
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);
        }
コード例 #24
0
        //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);
        }
コード例 #25
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();
        }
コード例 #27
0
 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);
     }
 }
コード例 #28
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();
        }
コード例 #29
0
        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);
        }
コード例 #30
0
        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();
        }