public int Save(LaboratoryModel laboratory) { if (laboratory.Description != null) { query = "INSERT INTO LaboratoryTable VALUES(@TEST,@DESCRIPTION)"; Command = new SqlCommand(query, Connection); Command.Parameters.AddWithValue("TEST", laboratory.Name); Command.Parameters.AddWithValue("DESCRIPTION", laboratory.Description); } else { query = "INSERT INTO LaboratoryTable(TestName) values(@TEST);"; Command = new SqlCommand(query, Connection); Command.Parameters.AddWithValue("TEST", laboratory.Name); } Connection.Open(); int rowEffect = Command.ExecuteNonQuery(); Connection.Close(); return(rowEffect); }
public void Post([FromBody] LaboratoryModelAPI laboratoryModelAPI) { var user = new LaboratoryModel() { Curricula = laboratoryModelAPI.Curricula, Description = laboratoryModelAPI.Description, LabDate = laboratoryModelAPI.LabDate, Number = laboratoryModelAPI.Number, Title = laboratoryModelAPI.Title }; laboratoryService.Add(user); }
public static LaboratoryModel Trim(this LaboratoryModel lab) { if (lab == null) { return(null); } lab.Assignments = null; lab.Attendances = null; return(lab); }
public void AddALaboratory(LaboratoryModel laboratory) { if (labRepo.GetByDate(laboratory.Date) != null || labRepo.GetByNumber(laboratory.Number) != null) { throw new Exception("laboratory already exists"); } laboratory.Id = 0; labRepo.Add(Mapper.Map <LaboratoryDto>(laboratory)); labRepo.Save(); }
public ActionResult MonthTest(int id) { Session["Choice"] = id == 1 ? "Concrete" : "Block"; LaboratoryModel model = new LaboratoryModel(); Nullable <int> month = 28; model.TestedSamples = db.ConcreteSample1.Where(s => s.IsReceived == true && DbFunctions.DiffDays(s.CreatedDate, DateTime.Now) == month).ToList(); return(View(model)); }
public LaboratoryModelAPI Map(LaboratoryModel lab) { return(new LaboratoryModelAPI() { Curricula = lab.Curricula, Date = lab.Date, Description = lab.Description, Number = lab.Number, Title = lab.Title }); }
//Get The 7 Days public ActionResult SevenDaysTest(int id) { Session["Choice"] = id == 1 ? "Concrete" : "Block"; LaboratoryModel model = new LaboratoryModel(); model.SevenDaysSamples = db.ConcreteSample1.Where(s => s.IsReceived == true && DbFunctions.DiffDays(s.CreatedDate, DateTime.Now) == 7).ToList(); return(View(model)); }
public async void update(LaboratoryModel lm) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpRequestMessage Req = new HttpRequestMessage(HttpMethod.Put, Baseurl + "api/Laboratory"); Req.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(lm), Encoding.ASCII, "application/json"); var Res = await client.PutAsync(Req.RequestUri, Req.Content); } }
public string Save(LaboratoryModel lab) { int rowEffect = laboratoryGateway.Save(lab); if (rowEffect > 0) { return("Save Successful"); } else { return("Save Faild"); } }
public LaboratoryModel map(Laboratory laboratory) { if (laboratory == null) { return(null); } var newLaboratory = new LaboratoryModel() { ID = laboratory.ID, Curricula = laboratory.Curricula, Description = laboratory.Description, LabDate = laboratory.LabDate, Number = laboratory.Number, Title = laboratory.Title }; return(newLaboratory); }
public ActionResult Laboratory(string id) { int number = int.Parse(id); var updated = db.ConcreteSample1.Where(s => s.SampleNumber == number).FirstOrDefault(); updated.labdeliver = true; db.SaveChanges(); LaboratoryModel model = new LaboratoryModel(); model.TodaySamples = db.ConcreteSample1.Where(s => s.IsReceived == true && DbFunctions.DiffDays(s.CreatedDate, DateTime.Now) == 1 && s.labdeliver == false).ToList(); return(View(model)); }
public LaboratoryAPIModel Map(LaboratoryModel laboratoryModel) { if (laboratoryModel == null) { return(null); } return(new LaboratoryAPIModel { LabNumber = laboratoryModel.LabNumber, Date = laboratoryModel.Date, Title = laboratoryModel.Title, Curricula = laboratoryModel.Curricula, Description = laboratoryModel.Description }); }
public async Task <ActionResult> LaboratoriesDelete(int?id, bool?saveChangesError = false) { if (Session["UserID"] != null && Session["UserType"].ToString() == "admin") { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (saveChangesError.GetValueOrDefault()) { ViewBag.ErrorMessage = "Delete failed. Try again!"; } LaboratoryModel laboratory = null; if (ModelState.IsValid) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string auth = Session["UserEmail"].ToString() + ":" + Session["UserPassword"]; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Authorization", auth); HttpRequestMessage Req = new HttpRequestMessage(HttpMethod.Get, Baseurl + "api/Laboratory/" + id); var response = await client.GetAsync(Req.RequestUri); var jsonString = await response.Content.ReadAsStringAsync(); laboratory = JsonConvert.DeserializeObject <LaboratoryModel>(jsonString); } } if (laboratory == null) { return(HttpNotFound()); } return(View(laboratory)); } else { return(RedirectToAction("Login", "Home")); } }
public async Task <ActionResult> LaboratoriesCreate(LaboratoryModel model) { //if (ModelState.IsValid) //{ using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string auth = Session["UserEmail"].ToString() + ":" + Session["UserPassword"]; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Authorization", auth); HttpRequestMessage Req = new HttpRequestMessage(HttpMethod.Post, Baseurl + "api/Laboratory"); Req.Content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(model), Encoding.ASCII, "application/json"); var response = await client.PostAsync(Req.RequestUri, Req.Content); if (response.IsSuccessStatusCode) { return(RedirectToAction("LaboratoriesIndex")); } } //} return(View()); }
public IHttpActionResult GetLabortorys(int filter) { var dt = bl.GetLabortorys(filter); LaboratoryModel labModel = new LaboratoryModel(); foreach (DataRow row in dt.Rows) { LaboratoryDTO lab = new LaboratoryDTO { id = int.Parse(row["id"].ToString()), name = row["name"].ToString() }; labModel.laboratory.Add(lab); } if (dt == null) { throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound)); } return(Json(labModel)); }
/// <inheritdoc/> public async Task <RequestResult <IEnumerable <LaboratoryModel> > > GetLaboratoryOrders(string bearerToken, string hdid, int pageIndex = 0) { RequestResult <IEnumerable <LaboratoryOrder> > delegateResult = await this.laboratoryDelegate.GetLaboratoryOrders(bearerToken, hdid, pageIndex).ConfigureAwait(true); if (delegateResult.ResultStatus == ResultType.Success) { return(new RequestResult <IEnumerable <LaboratoryModel> >() { ResultStatus = delegateResult.ResultStatus, ResourcePayload = LaboratoryModel.FromPHSAModelList(delegateResult.ResourcePayload), PageIndex = delegateResult.PageIndex, PageSize = delegateResult.PageSize, TotalResultCount = delegateResult.TotalResultCount, }); } else { return(new RequestResult <IEnumerable <LaboratoryModel> >() { ResultStatus = delegateResult.ResultStatus, ResultError = delegateResult.ResultError, }); } }
public void EditLaboratory(LaboratoryModel laboratory) { var existing = labRepo.GetById(laboratory.Id); if (existing.Number != laboratory.Number) { if (labRepo.GetByNumber(laboratory.Number) == null) { existing.Number = laboratory.Number; } else { throw new Exception("There already exists a lab with that number"); } } if (existing.Date != laboratory.Date) { if (labRepo.GetByDate(laboratory.Date) == null) { if (laboratory.Date < DateTime.Now) { throw new Exception("Date must be in the future"); } existing.Date = laboratory.Date; } else { throw new Exception("There already exists a lab with that Date"); } } existing.Title = laboratory.Title ?? existing.Title; existing.Curricula = laboratory.Curricula ?? existing.Curricula; existing.Description = laboratory.Description ?? existing.Description; labRepo.Edit(existing); labRepo.Save(); }
//-------show Laboratory------------------------------------ public List <LaboratoryModel> GetAllLaboratory() { query = "SELECT * FROM LaboratoryTable"; Command = new SqlCommand(query, Connection); List <LaboratoryModel> laboratoryList = new List <LaboratoryModel>(); Connection.Open(); Reader = Command.ExecuteReader(); while (Reader.Read()) { LaboratoryModel laboratory = new LaboratoryModel(); laboratory.Name = Reader["TestName"].ToString(); laboratory.Description = Reader["Descriptions"].ToString(); laboratory.Price = Convert.ToInt32(Reader["Price"]); laboratoryList.Add(laboratory); } Connection.Close(); return(laboratoryList); }
// PUT: api/Laboratory/5 public void Put([FromBody] LaboratoryModel value) { lServices.Update(value); }
public LaboratoryModel Get(int id) { LaboratoryModel lab = laboratoryService.GetById(id); return(lab); }
public void Put([FromBody] LaboratoryModel laboratoryModel) { laboratoryService.UpdateLaboratory(laboratoryModel); }
public void Add(LaboratoryModel laboratoryModel) { lRepo.Add(lMapper.Map(laboratoryModel)); }
public void Delete(LaboratoryModel laboratoryModel) { lRepo.Delete(lMapper.Map(laboratoryModel)); }
public void UpdateLaboratory(LaboratoryModel laboratoryModel) { _iLaboratoryRepository.Update(_iLaboratoryMapper.Map(laboratoryModel)); _iLaboratoryRepository.SaveChanges(); }
public void Update(LaboratoryModel laboratoryModel) { lRepo.Update(lMapper.Map(laboratoryModel)); }
public void DeleteLaboratory(LaboratoryModel laboratoryModel) { _iLaboratoryRepository.Delete(_iLaboratoryMapper.Map(laboratoryModel).LabNumber); _iLaboratoryRepository.SaveChanges(); }
public void AddLaboratory(LaboratoryModel laboratoryModel) { _iLaboratoryRepository.Add(_iLaboratoryMapper.Map(laboratoryModel)); _iLaboratoryRepository.SaveChanges(); }
public void Put(int id, [FromBody] LaboratoryModel data) { data.Id = id; labService.EditLaboratory(data); }
public void Post([FromBody] LaboratoryModel data) { labService.AddALaboratory(data); }
public void Update(LaboratoryModel laboratoryModel) { throw new NotImplementedException(); }