/// <summary> /// Insert a new value in the list /// </summary> /// <param name=<em>"value"</em>>New value to be inserted</param> // POST: api/Bed public IHttpActionResult Post(BedModel country) { if (!ModelState.IsValid) { return(BadRequest("Not a valid model")); } using (var ctx = new HTMEntities3()) { ctx.Beds.Add(new Bed() { id = country.id, Bed_Code = country.BedCode, Description = country.Description, Bed_Number = country.Bed_Number, InsertedOn = country.InsertedOn, InsertedBy = country.InsertedBy, IsActive = country.IsActive, IsDelete = country.IsDelete }); ctx.SaveChanges(); } return(Ok()); }
public Task <string> Save(BedModel aModel) { try { const string query = @"INSERT INTO tbl_IN_BED_INFO (RoomNo, FloorNo, Description, TypeOfBedId, DeptId, Charge, ServiceCharge, ServiceChargePCOrTk, BedStatus, UserName, BranchId,AdmissionCharge) VALUES (@RoomNo, @FloorNo, @Description, @TypeOfBedId, @DeptId, @Charge, @ServiceCharge, @ServiceChargePCOrTk, @BedStatus, @UserName, @BranchId,@AdmissionCharge)" ; Con.Open(); var cmd = new SqlCommand(query, Con); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@RoomNo", aModel.RoomNo); cmd.Parameters.AddWithValue("@FloorNo", aModel.FloorNo); cmd.Parameters.AddWithValue("@Description", aModel.Description); cmd.Parameters.AddWithValue("@TypeOfBedId", aModel.TypeOfBedId); cmd.Parameters.AddWithValue("@DeptId", aModel.DeptId); cmd.Parameters.AddWithValue("@Charge", aModel.Charge); cmd.Parameters.AddWithValue("@ServiceCharge", aModel.ServiceCharge); cmd.Parameters.AddWithValue("@ServiceChargePCOrTk", aModel.ServiceChargePcOrTk); cmd.Parameters.AddWithValue("@BedStatus", aModel.BedStatus); cmd.Parameters.AddWithValue("@UserName", aModel.UserName); cmd.Parameters.AddWithValue("@BranchId", GetBranchIdByuserNameOpenCon(aModel.UserName)); cmd.Parameters.AddWithValue("@AdmissionCharge", aModel.AdmissionCharge); cmd.ExecuteNonQuery(); Con.Close(); return(Task.FromResult("Save Successful")); } catch (Exception exception) { if (Con.State == ConnectionState.Open) { Con.Close(); } return(Task.FromResult(exception.ToString())); } }
public object AddBedToDb(BedModel newBed) { try { DbConnection.Open(); using var command = DbConnection.CreateCommand(); command.CommandText = @"INSERT INTO BEDS(IcuId, BedLayout, BedNo)" + "VALUES (@IcuId, @BedLayout, @BedNo);"; command.Parameters.AddWithValue(@"IcuId", newBed.IcuId); command.Parameters.AddWithValue(@"BedLayout", newBed.BedLayout); command.Parameters.AddWithValue(@"BedNo", newBed.BedNumber); command.Prepare(); command.ExecuteNonQuery(); return(AddBedStatusWhenBedAdded()); } catch (Exception e) { Console.WriteLine(e); return(HttpStatusCode.InternalServerError); } finally { CloseDb(); } }
public async Task <ActionResult <int> > CreateBed([FromBody] BedModel model) { //return Created($"{AppConstants.API_URL_PREFIX}/beds/", await Mediator.Send(new CreateBedCommand { Model = model })); return(Ok(await Mediator.Send(new CreateBedCommand { Model = model }))); }
//return bool public object AddNewBedConfiguration(BedModel newBed, string dbPath) { //_occupancy.BedList.Add(newBed.BedId, newBed); //return "Bed Added Successfully"; var bedDbObj = new BedDbOps(dbPath); return(bedDbObj.AddBedToDb(newBed)); }
public BedViewModel(BedModel value) { Id = value.Id; IsNew = value.IsNew; Value = value; WriteData(value); }
public void AddBed(BedModel newBed) { Client = new RestClient(BaseUrl); Request = new RestRequest("Configuration/PostBedModelData", Method.POST) { RequestFormat = DataFormat.Json }; Request.AddJsonBody(newBed); Response = Client.Execute(Request); MessageBox.Show(Response.StatusCode.Equals(HttpStatusCode.OK) ? "Bed is Added." : "Internal Server Error."); }
public async Task <HttpResponseMessage> Post([FromBody] BedModel aModel) { var formate = RequestFormat.JsonFormaterString(); try { if (string.IsNullOrEmpty(aModel.Description)) { return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = "Name is Null" })); } else { if (_gt.FncSeekRecordNew("tbl_IN_BED_INFO", "Id=" + aModel.BedId + "") == false) { if (_gt.FncSeekRecordNew("tbl_IN_BED_INFO", "Description='" + aModel.Description + "'") == true) { return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = "Name Already Exist" }, formate)); } else { string msg = await _gt.Save(aModel); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "success", Msg = msg }, formate)); } } else { string msg = await _gt.Update(aModel); return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "success", Msg = msg }, formate)); } } } catch (Exception ex) { return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation { Output = "error", Msg = ex.ToString() }, formate)); } }
private static void DeserializeDataFromClient(string data) { BedModel bm = JsonConvert.DeserializeObject <BedModel>(data); if (bm.EditData) { _vdm.OxygenPercent = bm.VentilatorDevice.OxygenPercent; _vdm.AirPressure = bm.VentilatorDevice.AirPressure; _vdm.BreathDuration = bm.VentilatorDevice.BreathDuration; _vdm.BreathingRate = bm.VentilatorDevice.BreathingRate; } Random random = new Random(); _vdm.BloodOxygenLevel = random.Next(); }
public void WhenQueryServerToAddNewBedAndRemoveAddedBedAssertNoException() { var bedModel = new BedModel() { BedId = 1234, BedNumber = "101", BedLayout = "MIDDLE", IcuId = "ICU01" }; _request = new RestRequest("Configuration/PostBedModelData", Method.POST) { RequestFormat = DataFormat.Json }; _request.AddJsonBody(bedModel); var response = _client.Execute(_request); var result = _deserializer.Deserialize <object>(response); Assert.NotNull(result); RemoveBed(bedModel.BedId); }
public Dictionary <int, BedModel> GetAllBedsFromDb() { var allBeds = new Dictionary <int, BedModel>(); try { DbConnection.Open(); using var command = DbConnection.CreateCommand(); command.CommandText = "SELECT BedId, IcuId, BedLayout, BedNo, Occupied from Beds NATURAL JOIN Bedstatus;"; command.Prepare(); command.ExecuteNonQuery(); var result = command.ExecuteReader(); while (result.Read()) { var bed = new BedModel { BedId = result.GetInt32(0), IcuId = result.GetString(1), BedLayout = result.GetString(2), BedNumber = result.GetString(3), BedStatus = result.GetBoolean(4).ToString() }; allBeds.Add(bed.BedId, bed); } return(allBeds); } catch (Exception exception) { Console.WriteLine(exception); return(null); } finally { CloseDb(); } }
public Task <string> Update(BedModel aModel) { try { string msg = ""; const string query = @"UPDATE tbl_IN_BED_INFO SET (RoomNo=@RoomNo, FloorNo=@FloorNo, Description=@Description, TyepOfBed=@TyepOfBed, DeptId=@DeptId, Charge=@Charge, ServiceCharge=@ServiceCharge, ServiceChargePCOrTk=@ServiceChargePCOrTk, BedStatus=@BedStatus, UserName=@UserName, BranchId=@BranchId,AdmissionCharge=@AdmissionCharge WHERE Id=@BedId"; Con.Open(); var cmd = new SqlCommand(query, Con); cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@BedId", aModel.BedId); cmd.Parameters.AddWithValue("@RoomNo", aModel.RoomNo); cmd.Parameters.AddWithValue("@FloorNo", aModel.FloorNo); cmd.Parameters.AddWithValue("@Description", aModel.Description); cmd.Parameters.AddWithValue("@TypeOfBed", aModel.TypeOfBedId); cmd.Parameters.AddWithValue("@DeptId", aModel.DeptId); cmd.Parameters.AddWithValue("@Charge", aModel.Charge); cmd.Parameters.AddWithValue("@ServiceCharge", aModel.ServiceCharge); cmd.Parameters.AddWithValue("@ServiceChargePCOrTk", aModel.ServiceChargePcOrTk); cmd.Parameters.AddWithValue("@BedStatus", aModel.BedStatus); cmd.Parameters.AddWithValue("@UserName", aModel.UserName); cmd.Parameters.AddWithValue("@BranchId", GetBranchIdByuserName(aModel.UserName)); cmd.Parameters.AddWithValue("@AdmissionCharge", aModel.AdmissionCharge); cmd.ExecuteNonQuery(); Con.Close(); return(Task.FromResult("Update Successful")); } catch (Exception exception) { if (Con.State == ConnectionState.Open) { Con.Close(); } return(Task.FromResult(exception.ToString())); } }
public BaseResponse <BedModel> SaveBed(BedModel request) { return(base.Save <ORG_Bed, BedModel>(request, (q) => q.BedID == request.BedID)); }
/// <inheritdoc /> public Task <bool> UpdateBedAsync(BedModel bedModel) { return(_bedRepository.ReplaceByIdAsync(bedModel.BedId, bedModel)); }
/// <inheritdoc /> public Task InsertBedAsync(BedModel bedModel) { return(_bedRepository.InsertAsync(bedModel)); }
public IActionResult PostBedModelData([FromBody] BedModel newBedModel) { this._config.AddNewBedConfiguration(newBedModel, DbOps.GetDbPath()); return(Ok(200)); }
public async Task <ActionResult> UpdateBed([FromBody] BedModel model) { await Mediator.Send(new UpdateBedCommand { Model = model }); return(NoContent()); }
public IHttpActionResult Post(BedModel baseRequest) { var response = service.SaveBed(baseRequest); return(Ok(response)); }