public bool Update(HMS_ManageHealth msg) { bool blResult = false; using (HealthManageSystemEntities db = new HealthManageSystemEntities()) { Manage_Health m = db.Manage_Health.Where(c => c.UID == msg.UID).Where(c => c.MHID == msg.MHID).FirstOrDefault(); if (m == null) { return blResult; } else { m.H_Alert1 = msg.H_Alert1; m.H_Alert2 = msg.H_Alert2; m.H_Alert3 = msg.H_Alert3; db.SaveChanges(); blResult = true; } } return true; }
public HMS_ManageHealth Remove(string UID, string MHID) { HMS_ManageHealth message; using (HealthManageSystemEntities db = new HealthManageSystemEntities()) { Manage_Health m = db.Manage_Health.Where(c => c.UID == UID).Where(c => c.MHID == MHID).FirstOrDefault(); if (m == null) { return null; } else { message = new HMS_ManageHealth { UID = m.UID,MHID = m.MHID }; db.Manage_Health.Remove(m); db.SaveChanges(); } } return message; }
public void PutMessage(HMS_ManageHealth msg) { if (!repository.Update(msg)) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotFound)); //404 } }
public HMS_ManageHealth Add(HMS_ManageHealth msg) { SqlConnection Conn = new SqlConnection(); Conn.ConnectionString = WebConfigurationManager.ConnectionStrings["HMSConnectionString"].ConnectionString; SqlCommand cmdtop1 = new SqlCommand("select TOP 1 MHID from Manage_Health ORDER BY MHID DESC", Conn); string newMHID = null; Conn.Open(); object obj = cmdtop1.ExecuteScalar(); Conn.Close(); if (obj != null) { Conn.Open(); var dateNo = DateTime.Now.ToString("yy"); var monthNo = DateTime.Now.ToString("MM"); string dr = cmdtop1.ExecuteScalar().ToString(); int drpluse = Convert.ToInt32(dr.Substring(5, 7)); drpluse++; string UNO = drpluse.ToString(); string showGF = UNO.PadLeft(7, '0'); newMHID = "MH" + dateNo + monthNo + showGF.ToString(); Conn.Close(); } else { newMHID = "MH13070000001"; } Conn.Close(); Manage_Health message = new Manage_Health { MHID = newMHID, UID = msg.UID, HID = msg.HID, H_Alert1 = msg.H_Alert1, H_Alert2 = msg.H_Alert2, H_Alert3 = msg.H_Alert3 }; //doesn't have GP using (HealthManageSystemEntities db = new HealthManageSystemEntities()) { db.Manage_Health.Add(message); db.SaveChanges(); msg = new HMS_ManageHealth { MHID = newMHID, UID = message.UID, HID = message.HID, H_Alert1 = message.H_Alert1, H_Alert2 = message.H_Alert2, H_Alert3 = message.H_Alert3 }; } return msg; }
public HttpResponseMessage PostMessage(HMS_ManageHealth msg) { HMS_ManageHealth newMsg = repository.Add(msg); var response = Request.CreateResponse(HttpStatusCode.Created, newMsg); response.Headers.Location = new Uri(Request.RequestUri, "/api/HMS_MH/" + newMsg.UID.ToString()); return response; }