public int AddSpeciality(SpecialtyViewModel model) { try { using (UserContext db = new UserContext()) { SpecialtyModel sp = new SpecialtyModel { Id = model.Id, Prefix = model.Prefix, SpecialityName = model.SpecialityName, FieldSpecialty = model.FieldSpecialty, ValidUntil = model.ValidUntil, Quality = model.Quality, Pictures = new List <PictureModel>(db.PicturesModels.Where(t => model.Templates.Contains(t.Id))) }; sp = db.Specialties.Add(sp); db.SaveChanges(); return(sp.Id); } } catch { return(0); } }
public JsonResult CreateProtocol(string data) { dynamic model = JsonConvert.DeserializeObject(data); string date = model.date.ToString(); int days = DateTime.Parse(date).Subtract(new DateTime(2020, 1, 1)).Days; int specid = int.Parse(model.specialty.ToString()); using (UserContext db = new UserContext()) { SpecialtyModel sp = db.Specialties.Find(specid); string protocolname = $"{days:D3}"; ProtocolModel pr = db.Protocols.Find(protocolname); if (pr != null) { int index = 0; while (pr != null) { index++; protocolname = $"{days:D3}.{index:D2}"; pr = db.Protocols.Find(protocolname); } } db.Protocols.Add(new ProtocolModel { ProtocolName = protocolname }); db.SaveChanges(); return(Json(protocolname + $"-{sp.Prefix}", JsonRequestBehavior.AllowGet)); } }
public ActionResult NewMarks(int specId) { MarkViewModel[] mv; using (UserContext db = new UserContext()) { SpecialtyModel sp = db.Specialties.Find(specId); if (sp == null) { return(null); } mv = sp.MarkModels.Select(t => new MarkViewModel(t)).ToArray(); if (!mv.Any()) { mv = new MarkViewModel[] { new MarkViewModel { HoursNumber = 0, Naming = "Итоговая аттестация", SpecialtyId = specId }, } } ; } return(PartialView(mv)); }
public JsonResult CheckSpeciality(string specialityname) { using (UserContext db = new UserContext()) { SpecialtyModel sp = db.Specialties.FirstOrDefault(t => t.SpecialityName.ToLower() == specialityname.ToLower()); return(Json(sp == null, JsonRequestBehavior.AllowGet)); } }
public ActionResult UpdateSpeciality(int Id) { using (UserContext db = new UserContext()) { SpecialtyModel sp = db.Specialties.Find(Id); SpecialtyViewModel vm = new SpecialtyViewModel(sp); return(PartialView(vm)); } }
public ActionResult Edit(string id) { string token = HttpContext.Session.GetString("access_token"); List <SpecialtyModel> specialties = APIservice.GetListById <SpecialtyModel>(id, "synapsenamespace=core&synapseentityname=specialty&synapseattributename=specialty_id&attributevalue=", token); SpecialtyModel specialty = specialties.Select(s => s).FirstOrDefault(); return(View("AddEditSpecialty", specialty)); }
public void AddSpeciality(SpecialtyModel specialty) { if (specialty != null) { Specialty newSpecialty = new Specialty() { Specialty1 = specialty.Speciality }; _domainObjectRepository.Create <Specialty>(newSpecialty); } }
public ActionResult CreateSpecialty(SpecialtyModel specialty) { if (ModelState.IsValid) { _specialityRepository.AddSpeciality(specialty); return(RedirectToAction("SpecialtiesList")); } else { return(View(specialty)); } }
public async Task <ActionResult <SpecialtyModel> > CreateSpecialty(SpecialtyModel specialty) { try { dBContext.Specialties.Add(specialty); await dBContext.SaveChangesAsync(); return(Ok(specialty)); } catch (Exception e) { return(StatusCode(410)); } }
public bool?RemoveSpeciality(int Id) { using (UserContext db = new UserContext()) { SpecialtyModel sp = db.Specialties.Find(Id); if (sp == null) { return(null); } db.MarkModels.RemoveRange(sp.MarkModels); db.Specialties.Remove(sp); db.SaveChanges(); return(true); } }
public ActionResult UpdateSpeciality(SpecialtyViewModel model) { using (UserContext db = new UserContext()) { SpecialtyModel sp = db.Specialties.Find(model.Id); sp.SpecialityName = model.SpecialityName; sp.Prefix = model.Prefix; sp.FieldSpecialty = model.FieldSpecialty; sp.ValidUntil = model.ValidUntil; sp.Quality = model.Quality; sp.Pictures.Clear(); model.Templates.ToList().ForEach(tr => sp.Pictures.Add(db.PicturesModels.Find(tr))); db.Entry(sp).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("SpecialityPartialPage")); } }
public async Task <IActionResult> UpdateSpecialty(SpecialtyModel specialty, long id) { try { if (id != specialty.IdSpecialty) { return(BadRequest()); } dBContext.Entry(specialty).State = EntityState.Modified; await dBContext.SaveChangesAsync(); return(NoContent()); } catch (Exception e) { bool specialtyExist = dBContext.Specialties.Any(e => e.IdSpecialty == id); if (!specialtyExist) { return(NotFound()); } return(StatusCode(410)); } }
private void mButtonEdit_Click(object sender, RoutedEventArgs e) { string title = mFieldTitle.Text; if (title == null || title.Equals("")) { MessageBox.Show("Укажите фамилию!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); return; } // Сохранение экземпляра таблицы в переменной Specialty specialty = tableModel[index].Specialty_Object; specialty.Title = title; int rowNum = tableModel[index].Row_Number; // Удаление старой записи tableModel.RemoveAt(index); // Создание обновленной модели SpecialtyModel specialtyModel = new SpecialtyModel(); specialtyModel.Row_Number = rowNum; specialtyModel.Specialty_Object = specialty; // Запись обновленной модели в GUI таблицу tableModel.Insert(index, specialtyModel); // Выборка записи таблицы из БД var specialtyBD = dbContext.Specialties.First(d => d.Specialty_Id == specialtyModel.Specialty_Object.Specialty_Id); // Изменение информации в строке specialtyBD.Title = title; // Сохранение изменений в БД dbContext.SaveChanges(); }
public SpecialtyesView() { InitializeComponent(); dbContext = new Clinic_DatabaseEntities(); dbContext.Specialties.Load(); var bindingList = dbContext.Specialties.Local.ToBindingList(); tableModel = new ObservableCollection <SpecialtyModel>(); for (int i = 0; i < bindingList.Count; i++) { SpecialtyModel specialtyModel = new SpecialtyModel(); specialtyModel.Row_Number = (i + 1); specialtyModel.Specialty_Object = bindingList[i]; tableModel.Add(specialtyModel); } mSpecialtyesTable.ItemsSource = tableModel; }
public ActionResult SaveSpecialty(SpecialtyModel specialtyModel) { string token = HttpContext.Session.GetString("access_token"); string sql = string.Empty; if (specialtyModel.specialty_id is null) { List <SpecialtyModel> specialties = APIservice.GetListById <SpecialtyModel>(specialtyModel.specialtycode, "synapsenamespace=core&synapseentityname=specialty&synapseattributename=specialtycode&attributevalue=", token); if (specialties.Count > 0) { this.toastNotification.AddErrorToastMessage("Specialty Code already exists."); specialtyModel = null; return(View("AddEditSpecialty", specialtyModel)); } specialtyModel.specialty_id = System.Guid.NewGuid().ToString(); } specialtyModel.statustext = specialtyModel.statuscode; string result = APIservice.PostObject <SpecialtyModel>(specialtyModel, "synapsenamespace=core&synapseentityname=specialty", token); if (result == "OK") { this.toastNotification.AddSuccessToastMessage("Specialty details is successfully saved."); } else { this.toastNotification.AddErrorToastMessage("Error while saving Specialty details."); } return(View("AddEditSpecialty", specialtyModel)); }
private void mButtonAdd_Click(object sender, RoutedEventArgs e) { string title = mFieldTitle.Text; if (title == null || title.Equals("")) { MessageBox.Show("Укажите название специальности!", "Ошибка!", MessageBoxButton.OK, MessageBoxImage.Error); return; } SpecialtyModel specialtyModel = new SpecialtyModel(); specialtyModel.Row_Number = tableModel.Count + 1; specialtyModel.Specialty_Object = new Specialty(); specialtyModel.Specialty_Object.Title = title; dbContext.Specialties.Add(specialtyModel.Specialty_Object); dbContext.SaveChanges(); tableModel.Add(specialtyModel); mFieldTitle.Text = ""; }
public ActionResult GetMarks(string data) { dynamic da = JsonConvert.DeserializeObject(data); using (UserContext db = new UserContext()) { Dictionary <int, int> dictionary = new Dictionary <int, int>(); foreach (var x in da) { UserModel user = db.UserModels.Find(int.Parse(x.userid.ToString())); if (user == null) { return(null); } SpecialtyModel spec = db.Specialties.Find(int.Parse(x.specid.ToString())); if (spec == null) { return(null); } dictionary.Add(user.Id, spec.Id); } return(PartialView(dictionary)); } }
public IActionResult SetSpecialty([FromBody] SpecialtyModel model) { _doctorService.SetSpecialty(UserId, model.SpecialtyId.ParseGuid()); return(Success()); }
public ActionResult CreateSpecialty() { SpecialtyModel specialty = new SpecialtyModel(); return(View(specialty)); }