private void Add() { if (SelectedPatient.FirstName != null && SelectedPatient.PatientAdress != null && SelectedPatient.LastName != null && SelectedPatient.PatientNumber != null) { if (!Regex.IsMatch(SelectedPatient.PatientNumber, "[0-9]{3}-[0-9]{3}-[0-9]{4}")) { SelectedPatient.PatientNumber = "000-000-0000"; } if (SelectedPatient.MidName == null) { SelectedPatient.MidName = " "; } if (DateTime.Compare(SelectedPatient.PatientBirthdate, DateTime.Now) > 0) { SelectedPatient.PatientBirthdate = DateTime.Now; } ButtonResult result = ButtonResult.OK; if (ButtonName == "add") { repo.Add(SelectedPatient); } else { repo.Update(SelectedPatient); } RequestClose(new DialogResult(result)); } }
private void UpdateAuth(string cardPkId, IList <Device> devices) { var repo = new BaseRepo <CardAuth>(dbCtx); var existsList = repo.Find(t => t.Card == cardPkId); foreach (var e in existsList) { repo.Delete(e); } if (devices != null && devices.Count > 0) { var updateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); foreach (var dev in devices) { var entity = new CardAuth() { Card = cardPkId, Device = dev.PkId, UpdateTime = updateTime }; entity.NewId(); repo.Add(entity); } } }
private void AddOrUpdateCard(CardInfo card) { var repo = new BaseRepo <CardInfo>(dbCtx); CardInfo existsCard = null; if (!string.IsNullOrEmpty(card.PkId)) { existsCard = repo.Find(card.PkId); } else if (!string.IsNullOrEmpty(card.CardNo)) { existsCard = repo.Find(t => t.CardNo == card.CardNo).FirstOrDefault(); } card.UpdateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); if (existsCard == null) { card.NewId(); repo.Add(card); } else { existsCard.UpdateTime = card.UpdateTime; existsCard.User = card.User; existsCard.SerialNo = card.SerialNo; existsCard.CardType = card.CardType; existsCard.InvalidDate = card.InvalidDate; repo.Update(existsCard); card.PkId = existsCard.PkId; } }
private void AddOrUpdateUser(UserInfo user) { var repo = new BaseRepo <UserInfo>(dbCtx); UserInfo existsUser = null; if (!string.IsNullOrEmpty(user.PkId)) { existsUser = repo.Find(user.PkId); } else if (!string.IsNullOrEmpty(user.IdentityNumber)) { existsUser = repo.Find(t => t.IdentityNumber == user.IdentityNumber).FirstOrDefault(); } if (existsUser == null) { user.NewId(); repo.Add(user); } else { existsUser.Name = user.Name; existsUser.Phone = user.Phone; existsUser.IdentityNumber = user.IdentityNumber; //todo: other fields user.PkId = existsUser.PkId; repo.Update(existsUser); } }
public ActionResult Create([Bind(Include = "FolderName,ParentFolder")] Folder folder) { if (ModelState.IsValid) { _repo.Add(folder); return(RedirectToAction("Index")); } return(View(folder)); }
public ActionResult BookAdd(Book book) { if (book == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } else { repo.Add(book); return(new HttpStatusCodeResult(HttpStatusCode.OK)); } }
static void Main(string[] args) { BaseRepo <Car> cars = new BaseRepo <Car>(); WriteLine("******Cars******"); foreach (var car in cars.GetAll()) { WriteLine(car); } cars.Add(new Car { Make = "make1", Color = "color1", PetName = "name1" }); WriteLine("***Add car***"); cars.AddRange(new List <Car>() { new Car { Make = "make2", Color = "color2", PetName = "name2" }, new Car { Make = "make3", Color = "color3", PetName = "name3" } }); WriteLine("***Add cars***"); WriteLine("******Cars******"); foreach (var car in cars.GetAll()) { WriteLine(car); } cars.GetOne(1).Color = "blue"; WriteLine("***Update car***"); WriteLine("******Cars******"); foreach (var car in cars.GetAll()) { WriteLine(car); } cars.Delete(cars.GetOne(5)); WriteLine("***Delete car***"); WriteLine("******Cars******"); foreach (var car in cars.GetAll()) { WriteLine(car); } ReadKey(); }
private void Add() { if (TDiagnosis.DiagnosisName != null && TDiagnosis.DiagnosisTreatment != null) { ButtonResult result = ButtonResult.OK; if (ButtonName == "add") { repo.Add(TDiagnosis); } else { repo.Update(TDiagnosis); } RequestClose(new DialogResult(result)); } }
public ActionResult Create([Bind(Include = "FileName,DescriptionFile, Content")] File file) { if (ModelState.IsValid) { Folder folder = _repoFolder.GetOne((int)TempData["item"]); if (folder == null) { return(HttpNotFound()); } file.Content = TempData["FileData"] as string; file.ExtensionId = 1; file.FolderId = ((int)TempData["item"]); _repo.Add(file); return(RedirectToAction("Index", "Folder")); } return(View(file)); }
public void Add(T entity) { ProcessReceivers(entity, EventType.EntityAdding); BaseRepo.Add(entity); ProcessReceivers(entity, EventType.EntityAdded); }