public bool InsertUpdateDeleteSpectroMaster(ENT.SpectroMaster objENT) { bool row = false; try { sqlCMD = new SqlCommand(); sqlCMD.CommandText = "InsertUpdateDeleteSpectroMaster"; sqlCMD.Parameters.AddWithValue("@SpectroID", objENT.SpectroID); sqlCMD.Parameters.AddWithValue("@SpectroNo", objENT.SpectroNo); sqlCMD.Parameters.AddWithValue("@SpectroDate", objENT.SpectroDate); sqlCMD.Parameters.AddWithValue("@Quality", objENT.Quality); sqlCMD.Parameters.AddWithValue("@Grade", objENT.Grade); sqlCMD.Parameters.AddWithValue("@SampleNo", objENT.SampleNo); sqlCMD.Parameters.AddWithValue("@Mode", objENT.Mode); row = objCRUD.InsertUpdateDelete(sqlCMD); } catch (Exception ex) { throw ex; } return(row); }
public HttpResponseMessage SaveSpectroMaster(ENT.SpectroMaster Model) { bool IsSuccess = false, IsSendToFcm = false; string ResMessage = string.Empty; try { #region Send Spectro Data To FCM FCMRootObject FCMData = new FCMRootObject(); Notification NotificationBody = new Notification(); Data NotificationData = new Data(); int count = 0; List <ENT.Device> lstENT = getDeviceID(); for (int i = 0; i < lstENT.Count; i++) { if (!string.IsNullOrWhiteSpace(lstENT[i].DeviceId)) { FCMData.to = lstENT[i].DeviceId; NotificationData.Description = Model.SpectroJson; NotificationBody.title = "GI ADMIN"; NotificationBody.body = Model.SpectroJson; FCMData.data = NotificationData; // FCMData.notification = NotificationBody; FCMResponse s = new FCMSender().SendClientNotification(FCMData); if (s.success > 0) { count++; } } } if (count == lstENT.Count) { IsSendToFcm = true; } else { IsSendToFcm = false; } ResMessage = count.ToString() + " notification send successfull out of " + lstENT.Count + "."; #endregion #region Save Master To Local Database Int64 SpectroNo = new DAL.SpectroEntry().GetTopOneSpectroNo(); Model.Mode = "ADD"; Model.SpectroID = Guid.NewGuid(); Model.SpectroNo = SpectroNo + 1; DateTime dt1 = DateTime.Now; string[] dtDate = Model.SpectroDate.Split('/'); if (dtDate.Length == 3) { dt1 = new DateTime(Convert.ToInt32(dtDate[2]), Convert.ToInt32(dtDate[0]), Convert.ToInt32(dtDate[1])); } Model.SpectroDate = dt1.ToString("dd/MMM/yyyy"); if (new DAL.SpectroEntry().InsertUpdateDeleteSpectroMaster(Model)) { ResMessage += " Entry Save Successfully."; IsSuccess = true; } else { ResMessage += " Entry Not Save Successfully."; IsSuccess = false; } #endregion } catch (Exception ex) { ResMessage += ResMessage + " Error: " + ex.Message; IsSuccess = false; ERRORREPORTING.Report(ex, Request.RequestUri.AbsoluteUri, new Guid("00000000-0000-0000-0000-000000000000"), "Gujarat_Intrux", "Function Name : SaveSpectroMaster()"); return(ControllerContext.Request.CreateResponse(HttpStatusCode.InternalServerError, new { ResMessage, IsSuccess, IsSendToFcm })); } return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { ResMessage, IsSuccess, IsSendToFcm })); }