Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 public static LaboratoryModel Trim(this LaboratoryModel lab)
 {
     if (lab == null)
     {
         return(null);
     }
     lab.Assignments = null;
     lab.Attendances = null;
     return(lab);
 }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
 public LaboratoryModelAPI Map(LaboratoryModel lab)
 {
     return(new LaboratoryModelAPI()
     {
         Curricula = lab.Curricula,
         Date = lab.Date,
         Description = lab.Description,
         Number = lab.Number,
         Title = lab.Title
     });
 }
Ejemplo n.º 7
0
        //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));
        }
Ejemplo n.º 8
0
 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");
            }
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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));
        }
Ejemplo n.º 12
0
        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
            });
        }
Ejemplo n.º 13
0
        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"));
            }
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 16
0
        /// <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,
                });
            }
        }
Ejemplo n.º 17
0
        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();
        }
Ejemplo n.º 18
0
        //-------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);
        }
Ejemplo n.º 19
0
 // PUT: api/Laboratory/5
 public void Put([FromBody] LaboratoryModel value)
 {
     lServices.Update(value);
 }
Ejemplo n.º 20
0
        public LaboratoryModel Get(int id)
        {
            LaboratoryModel lab = laboratoryService.GetById(id);

            return(lab);
        }
Ejemplo n.º 21
0
 public void Put([FromBody] LaboratoryModel laboratoryModel)
 {
     laboratoryService.UpdateLaboratory(laboratoryModel);
 }
Ejemplo n.º 22
0
 public void Add(LaboratoryModel laboratoryModel)
 {
     lRepo.Add(lMapper.Map(laboratoryModel));
 }
Ejemplo n.º 23
0
 public void Delete(LaboratoryModel laboratoryModel)
 {
     lRepo.Delete(lMapper.Map(laboratoryModel));
 }
Ejemplo n.º 24
0
 public void UpdateLaboratory(LaboratoryModel laboratoryModel)
 {
     _iLaboratoryRepository.Update(_iLaboratoryMapper.Map(laboratoryModel));
     _iLaboratoryRepository.SaveChanges();
 }
Ejemplo n.º 25
0
 public void Update(LaboratoryModel laboratoryModel)
 {
     lRepo.Update(lMapper.Map(laboratoryModel));
 }
Ejemplo n.º 26
0
 public void DeleteLaboratory(LaboratoryModel laboratoryModel)
 {
     _iLaboratoryRepository.Delete(_iLaboratoryMapper.Map(laboratoryModel).LabNumber);
     _iLaboratoryRepository.SaveChanges();
 }
Ejemplo n.º 27
0
 public void AddLaboratory(LaboratoryModel laboratoryModel)
 {
     _iLaboratoryRepository.Add(_iLaboratoryMapper.Map(laboratoryModel));
     _iLaboratoryRepository.SaveChanges();
 }
Ejemplo n.º 28
0
 public void Put(int id, [FromBody] LaboratoryModel data)
 {
     data.Id = id;
     labService.EditLaboratory(data);
 }
Ejemplo n.º 29
0
 public void Post([FromBody] LaboratoryModel data)
 {
     labService.AddALaboratory(data);
 }
Ejemplo n.º 30
0
 public void Update(LaboratoryModel laboratoryModel)
 {
     throw new NotImplementedException();
 }