public object ThemLoaiXetNghiemVaoMauBenhAn(FormCollection collec) { try { if (collec["mauBenhAn_LXN"] != null) { MauBenhAn_LoaiXetNghiem mauBenhAn_LXN = JsonConvert.DeserializeObject <MauBenhAn_LoaiXetNghiem>(collec["mauBenhAn_LXN"]); MauBenhAn mauBenhAn = MauBenhAnService.GetSingleById(mauBenhAn_LXN.id_MauBenhAn); MauBenhAn_LoaiXetNghiem timDuoc = MauBenhAnService.DbContext.MauBenhAn_LoaiXetNghiem.Where(mauBA => mauBA.id_MauBenhAn == mauBenhAn_LXN.id_MauBenhAn && mauBA.id_LoaiXetNghiem == mauBenhAn_LXN.id_LoaiXetNghiem).FirstOrDefault(); if (timDuoc != null) { return(false); } mauBenhAn_LXN.ThuTu = mauBenhAn.MauBenhAn_LoaiXetNghiem.Count + 1; MauBenhAnService.DbContext.MauBenhAn_LoaiXetNghiem.Add(mauBenhAn_LXN); MauBenhAnService.Commit(); return(true); } return(false); } catch { return(false); } }
public object CapNhatTrangThai(MauBenhAn mauBenhAn) { try { MauBenhAn mauBenhAnCapNhat = MauBenhAnService.GetSingleById(mauBenhAn.id); mauBenhAnCapNhat.TrangThai = mauBenhAn.TrangThai; MauBenhAnService.Commit(); return(true); } catch (Exception ex) { return(ex); } }
public object Edit(FormCollection collec) { try { if (collec["mauBenhAn_LXN"] != null) { MauBenhAn_LoaiXetNghiem mauBenhAn_LXN = JsonConvert.DeserializeObject <MauBenhAn_LoaiXetNghiem>(collec["mauBenhAn_LXN"]); MauBenhAn mauBenhAn = MauBenhAnService.GetSingleById(mauBenhAn_LXN.id_MauBenhAn); MauBenhAn_LoaiXetNghiem timDuoc = mauBenhAn.MauBenhAn_LoaiXetNghiem.Where(lxn => lxn.id_LoaiXetNghiem == mauBenhAn_LXN.id_LoaiXetNghiem).FirstOrDefault(); timDuoc.ThuTu = mauBenhAn_LXN.ThuTu; MauBenhAnService.Commit(); return(true); } return(false); } catch { return(false); } }
public object Create(MauBenhAn mauBenhAn) { try { string strPattern = @"[\s]+"; Regex rgx = new Regex(strPattern); string Ouput = rgx.Replace(convertToUnSign3(mauBenhAn.TenMauBenhAn), " "); Ouput = Ouput.Replace(" ", ""); if (MauBenhAnService.Count(mba => mba.TenMauBenhAn.ToLower() == mauBenhAn.TenMauBenhAn.ToLower()) > 0) { return(false); } if (MauBenhAnService.Count(mba => mba.TenKhongDau == Ouput) > 0) { int i = 1; string fixOutPut = Ouput + i.ToString(); while (MauBenhAnService.Count(mba => mba.TenKhongDau == fixOutPut) > 0) { i++; fixOutPut = Ouput + i.ToString(); } mauBenhAn.TenKhongDau = fixOutPut; } else { mauBenhAn.TenKhongDau = Ouput; } MauBenhAnService.dbSet.Add(mauBenhAn); MauBenhAnService.Commit(); return(true); } catch (Exception ex) { return(new { error = ex.Message }); } }