public async Task <HttpResponseMessage> CreateAsync(MT_Instrument IMD) { Db = con.SurgeryCenterDb(IMD.Slug); InstrumentResponse Response = new InstrumentResponse(); try { UniqueID = con.GetUniqueKey(); IMD.Instru_Unique_ID = UniqueID; IMD.Instru_Create_Date = con.ConvertTimeZone(IMD.Instru_TimeZone, Convert.ToDateTime(IMD.Instru_Create_Date)); IMD.Instru_Modify_Date = con.ConvertTimeZone(IMD.Instru_TimeZone, Convert.ToDateTime(IMD.Instru_Modify_Date)); DocumentReference docRef = Db.Collection("MT_Instrument").Document(UniqueID); WriteResult Result = await docRef.SetAsync(IMD); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = IMD; } else { Response.Status = con.StatusNotInsert; Response.Message = con.MessageNotInsert; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
//[Authorize(Roles = "Admin")] public async Task <HttpResponseMessage> Select(MT_Instrument IMD) { Db = con.SurgeryCenterDb(IMD.Slug); InstrumentResponse Response = new InstrumentResponse(); try { MT_Instrument AnesList = new MT_Instrument(); Query docRef = Db.Collection("MT_Instrument").WhereEqualTo("Instru_Unique_ID", IMD.Instru_Unique_ID).WhereEqualTo("Instru_Is_Deleted", false); QuerySnapshot ObjQuerySnap = await docRef.GetSnapshotAsync(); if (ObjQuerySnap != null) { AnesList = ObjQuerySnap.Documents[0].ConvertTo <MT_Instrument>(); Response.Data = AnesList; } Response.Status = con.StatusNotDeleted; Response.Message = con.MessageNotDeleted; } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
//[Authorize(Roles ="SAdmin")] public async Task <HttpResponseMessage> GetDeletedList(MT_Instrument IMD) { Db = con.SurgeryCenterDb(IMD.Slug); InstrumentResponse Response = new InstrumentResponse(); try { List <MT_Instrument> AnesList = new List <MT_Instrument>(); Query docRef = Db.Collection("MT_Instrument").WhereEqualTo("Instru_Is_Deleted", true); QuerySnapshot ObjQuerySnap = await docRef.GetSnapshotAsync(); if (ObjQuerySnap != null) { foreach (DocumentSnapshot Docsnapshot in ObjQuerySnap.Documents) { AnesList.Add(Docsnapshot.ConvertTo <MT_Instrument>()); } Response.DataList = AnesList.OrderBy(o => o.Instru_Name).ToList(); } Response.Status = con.StatusNotDeleted; Response.Message = con.MessageNotDeleted; } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <HttpResponseMessage> Remove(MT_Instrument IMD) { Db = con.SurgeryCenterDb(IMD.Slug); InstrumentResponse Response = new InstrumentResponse(); try { DocumentReference docRef = Db.Collection("MT_Instrument").Document(IMD.Instru_Unique_ID); WriteResult Result = await docRef.DeleteAsync(); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = null; } else { Response.Status = con.StatusNotDeleted; Response.Message = con.MessageNotDeleted; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }
public async Task <HttpResponseMessage> UpdateAsync(MT_Instrument IMD) { Db = con.SurgeryCenterDb(IMD.Slug); InstrumentResponse Response = new InstrumentResponse(); try { Dictionary <string, object> initialData = new Dictionary <string, object> { { "Instru_Name", IMD.Instru_Name }, { "Instru_Type", IMD.Instru_Type }, { "Instru_Description", IMD.Instru_Description }, { "Instru_Modify_Date", con.ConvertTimeZone(IMD.Instru_TimeZone, Convert.ToDateTime(IMD.Instru_Modify_Date)) }, { "Instru_Surgery_Physician_Id", IMD.Instru_Surgery_Physician_Id } }; DocumentReference docRef = Db.Collection("MT_Instrument").Document(IMD.Instru_Unique_ID); WriteResult Result = await docRef.UpdateAsync(initialData); if (Result != null) { Response.Status = con.StatusSuccess; Response.Message = con.MessageSuccess; Response.Data = IMD; } else { Response.Status = con.StatusNotUpdate; Response.Message = con.MessageNotUpdate; Response.Data = null; } } catch (Exception ex) { Response.Status = con.StatusFailed; Response.Message = con.MessageFailed + ", Exception : " + ex.Message; } return(ConvertToJSON(Response)); }