public IHttpActionResult UpdateReport(object report) { ReportMobileInputDTO temp = ((Newtonsoft.Json.Linq.JObject)report).ToObject <ReportMobileInputDTO>(); string strUserID = temp.StrUserID; Library.DTO.Notification notification = new Library.DTO.Notification(); int? UserID = fwBll.GetUserIDFromSecreteKey(strUserID, out notification); object data = null; if (UserID.HasValue) { // authentication if (!fwBll.CanPerformAction(UserID.Value, moduleCode, Library.DTO.ModuleAction.CanUpdate)) { return(InternalServerError(new Exception(Properties.Resources.NOT_AUTHORIZED))); } System.Collections.Hashtable inputs = new System.Collections.Hashtable(); inputs["report"] = temp; data = executor.CustomFunction(UserID.Value, "api-update-report", inputs, out notification); } return(Ok(data)); }
public bool UpdateReportFromMobile(int userID, object dtoItem, out Library.DTO.Notification notification) { ReportMobileInputDTO temp = (ReportMobileInputDTO)dtoItem; notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { using (QAQCMngEntities context = CreateContext()) { foreach (var item in temp.ReportQAQCDTOs) { int?reportQAQCID = context.QAQCMng_function_UpdateReportQAQC(item.QAQCID, item.TypeOfInspectionID, item.FinishedDate.ConvertStringToDateTime(), item.Remark, item.ReadyQty, item.StatusID, item.ManagementStringID, item.IsSynced, item.SyncedDate.ConvertStringToDateTime(), item.CreatedDate.ConvertStringToDateTime(), item.CheckedQty, userID, userID, CreateImageFromName(item.ImageName), item.LatitudeC, item.LongitudeC, item.LatitudeF, item.LongitudeF).FirstOrDefault(); if (reportQAQCID.HasValue) { if (item.ReportCheckListDTOs != null) { foreach (var reportCheckListDTO in item.ReportCheckListDTOs) { int?reportCheckListID = context.QAQCMng_function_UpdateReportCheckList(reportQAQCID, reportCheckListDTO.CheckListID, reportCheckListDTO.Remark, reportCheckListDTO.StatusID, reportCheckListDTO.CheckListMobileStringID, userID, userID).FirstOrDefault(); if (reportCheckListID != null && reportCheckListID.HasValue) { foreach (var reportCheckListImageDTO in reportCheckListDTO.ReportCheckListImageDTOs) { int?reportCheckListImageID = context.QAQCMng_function_UpdateReportCheckListImage(reportCheckListID, CreateImageFromName(reportCheckListImageDTO.ImageBase64), reportCheckListImageDTO.CheckListImageStringID, userID, userID).FirstOrDefault(); } } } } if (item.ReportDefectDTOs != null) { foreach (var reportDefectDTO in item.ReportDefectDTOs) { int?reportDefectID = context.QAQCMng_function_UpdateReportDefect(reportQAQCID, reportDefectDTO.DefectID, reportDefectDTO.DefectAQty, reportDefectDTO.DefectBQty, reportDefectDTO.DefectCQty, reportDefectDTO.DefectMobileStringID, userID, userID).FirstOrDefault(); if (reportDefectID != null && reportDefectID.HasValue) { foreach (var reportDefectImage in reportDefectDTO.ReportDefectImageDTOs) { int?reportDefectImageID = context.QAQCMng_function_UpdateReportDefectImage(reportDefectID, CreateImageFromName(reportDefectImage.ImageBase64), reportDefectImage.DefectImageMobileStringID, userID, userID).FirstOrDefault(); } } } } } } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = ex.Message; return(false); } return(true); }