public object Put([FromBody] InspectionModel model) { var output = new ResponseDetail(); try { if (ModelState.IsValid) { var inspection = Mapper.Map <Inspections>(model); _inspectionService.UpdateInspection(inspection); output.Success = true; output.Message = "Inspection Updated Successfully"; return(output); } output.Success = false; output.Message = "Something went wrong!"; return(output); } catch (Exception ex) { output.Success = false; output.Message = ex.Message; return(output); } }
public InspectionDetail(int id, InspectionModel context = null) { InitializeComponent(); currentPatientId = id; if (context == null) { context = new InspectionModel(); } else { using (var db = new PatientContext()) { var ins = context; context.LeftEye = db.Eyes.Single(p => p.Id == ins.LeftEyeId); context.RightEye = db.Eyes.Single(p => p.Id == ins.RightEyeId); } } //给context的病人对象赋值 using (var db = new PatientContext()) { var patient = db.Patients.Single(p => p.Id == id); context.BirthDate = patient.BirthDate; } DataContext = context; }
public JsonResult EvaluateInspection(InspectionModel model) { var request = db.Inspection.FirstOrDefault(x => x.Id == model.Id); if (request == null) { return(Json(new { Success = false, Message = "No record found!" })); } if (ModelState.IsValid) { request.StatusId = model.StatusId; request.Reason = model.Reason; request.OwnerUpdate = true; try { db.SaveChanges(); } catch (Exception ex) { return(Json(new { Success = false, ErrorMsg = ex.ToString() })); } } else { return(Json(new { Success = false, ErrorMsg = "Invalid Fields." })); } return(Json(new { Success = true, Message = "Evaluation Submitted Successfully" })); }
public async Task <IHttpActionResult> Put(int inspectionId, InspectionModel inspectionModel) { if (!ModelState.IsValid) { return(BadRequest("Inspection Model is not valid")); } try { using (var context = new BeeAppContext()) { var inspection = await context.Beekeepers .Where(x => x.ApplicationUserId == _applicationUserId) .Include(x => x.Apiaries) .SelectMany(x => x.Apiaries) .Include(x => x.Hives) .SelectMany(x => x.Hives) .Include(x => x.Inspections) .SelectMany(x => x.Inspections) .Where(x => x.Id == inspectionId) .FirstOrDefaultAsync(); if (inspection != null) { inspection.Name = inspectionModel.Name; inspection.Date = inspectionModel.Date; inspection.Strength = inspectionModel.Strength; inspection.Temper = inspectionModel.Temper; inspection.Disease = inspectionModel.Disease; inspection.FramesBees = inspectionModel.FramesBees; inspection.FramesHoney = inspectionModel.FramesHoney; inspection.FramesHoneySupers = inspectionModel.FramesHoneySupers; inspection.Drones = inspectionModel.Drones; inspection.DroneCells = inspectionModel.DroneCells; // Save context.SaveChanges(); // Return return(StatusCode(HttpStatusCode.NoContent)); } // Return return(BadRequest("Inspection could not be found")); } } catch (Exception ex) { // Return return(BadRequest(ex.Message)); } }
public static ServiceResponseResult EditInspection(InspectionModel model, Login login, HttpFileCollectionBase files) { using (var db = new KeysEntities()) { var editInspection = db.Inspection.Where(x => x.Id == model.Id).First(); if (editInspection != null) { editInspection.IsUpdated = true; editInspection.PercentDone = model.PercentDone; editInspection.Message = model.Message; editInspection.UpdatedBy = login.Id; editInspection.UpdatedOn = DateTime.UtcNow; if (model.FilesRemoved.Count > 0) { foreach (var file in model.FilesRemoved) { var removeFile = db.InspectionMedia.Find(file); db.InspectionMedia.Remove(removeFile); MediaService.RemoveMediaFile(removeFile.NewFileName); } } var fileList = MediaService.SaveFiles(files, 5 - editInspection.InspectionMedia.Count, AllowedFileType.AllFiles).NewObject as List <MediaModel>; if (fileList != null) { fileList.ForEach(x => editInspection.InspectionMedia.Add(new InspectionMedia { NewFileName = x.NewFileName, InspectionId = editInspection.Id, OldFileName = x.OldFileName, IsActive = true })); } } ; try { db.SaveChanges(); var mediaFiles = editInspection.InspectionMedia.Select(x => MediaService.GenerateViewProperties(new MediaModel { NewFileName = x.NewFileName, OldFileName = x.OldFileName })).ToList(); mediaFiles = mediaFiles ?? new List <MediaModel>(); return(new ServiceResponseResult { IsSuccess = true, NewObject = mediaFiles }); } catch (Exception ex) { return(new ServiceResponseResult { IsSuccess = true, ErrorMessage = _error }); } } }
public static ServiceResponseResult AddInspection(InspectionModel model, Login login, HttpFileCollectionBase files) { using (var db = new KeysEntities()) { var request = db.PropertyRequest.Where(x => x.Id == model.RequestId).FirstOrDefault(); if (request.RequestTypeId == 3) { var replyRequest = new Inspection { RequestId = model.RequestId, Message = model.Message, CreatedBy = login.Id, CreatedOn = DateTime.UtcNow, UpdatedBy = login.Id, UpdatedOn = DateTime.UtcNow, IsActive = true, PropertyId = model.PropertyId, StatusId = 1, PercentDone = model.PercentDone, OwnerUpdate = false, IsViewed = false, IsUpdated = false }; db.Inspection.Add(replyRequest); var fileList = MediaService.SaveFiles(files, 5, AllowedFileType.AllFiles).NewObject as List <MediaModel>; if (fileList != null) { fileList.ForEach(x => replyRequest.InspectionMedia.Add(new InspectionMedia { NewFileName = x.NewFileName, InspectionId = replyRequest.Id, OldFileName = x.OldFileName, IsActive = true })); } } request.RequestStatusId = 2; try { db.SaveChanges(); return(new ServiceResponseResult { IsSuccess = true }); } catch (Exception ex) { return(new ServiceResponseResult { IsSuccess = true, ErrorMessage = _error }); } } }
public static SelectResult <InspectionModel> GetInspectionInfoByID(long ID) { string sql = @"SELECT OBJECT_TYPE AS ObjType , OBJECT_ID AS ObjID , AccessCode , Version , CAST(M1 AS INT) M1 , CAST(IA1 AS INT) IA1 , CAST(IC1 AS INT) IC1 , FLAG, PLATNAMR AS PlatformName FROM InspectionServer.TMS.dbo.TB_PLATFORM_CHECKMSG WHERE MSG_ID = @ID"; List <SqlParameter> paras = new List <SqlParameter>() { new SqlParameter() { ParameterName = "@ID", Value = ID.ToString(), }, }; List <InspectionModel> list = ConvertToList <InspectionModel> .Convert(MSSQLHelper.ExecuteDataTable(CommandType.Text, sql, paras.ToArray())); InspectionModel data = null; string msg = string.Empty; if (list == null) { msg = PromptInformation.DBError; } else if (list.Count == 0) { msg = PromptInformation.NotExists; } else { data = list[0]; } return(new SelectResult <InspectionModel>() { DataResult = data, Message = msg }); }
public Chart(PatientModel model, InspectionModel currentInspection, bool ageChart = true) { InitializeComponent(); pwi = new PatientWithInspection(); pwi.Patient = model; pwi.Inspection = currentInspection; this.leftEye = leftEye; DataContext = pwi; this.ageChart = ageChart; if (!ageChart) { tbDesc.Text = "身 高(0-180cm)"; } DrawArea(model); }
public ActionResult Index(InspectionModel inspectionModel) { year = inspectionModel.years; week = inspectionModel.weeks; ViewBag.YearList = commonUtility.Years(); ViewBag.WeekList = commonUtility.Weeks(); var data = inspectionRepository.GetAll(); if (year != null && week != null) { var filterByYearAndWeek = inspectionUtility. FilterByYearAndWeek(Convert.ToInt32(year), Convert.ToInt32(week)).Values; ViewBag.WeeklyAmount = filterByYearAndWeek.Sum(w => w.Amount); inspectionModel.Inspections = filterByYearAndWeek; } if (year != null && week == null) { var filterByYear = inspectionUtility. FilterByYear(Convert.ToInt32(year)).Values; inspectionModel.Inspections = filterByYear; } if (year == null && week != null) { //var filterByWeek = inspectionUtility. // FilterByYear(Convert.ToInt32(week)).Values; //inspectionModel.Inspections = filterByWeek; TempData["Message"] = "You can not send filter just only use week, please select year also"; return(RedirectToAction("Messages", "Inspection")); } if (year == null && week == null) { year = Convert.ToString(DateTime.Now.Year); week = Convert.ToString(commonUtility.GetWeekNumber(DateTime.Now)); var filterByYearAndWeek = inspectionUtility. FilterDefault(Convert.ToInt32(year), Convert.ToInt32(week)).Values; ViewBag.WeeklyAmount = filterByYearAndWeek.Sum(w => w.Amount); inspectionModel.Inspections = filterByYearAndWeek; } return(View(inspectionModel)); }
public async Task <ActionResult> EditInspection(InspectionModel model) { model = new InspectionModel(); model.ServiceRequest = new ServiceRequestModel(); model.SideNavModels = new List <NavigationModel>(); #region NavigationsForCustomer //Navigation for an Employee model.SideNavModels.Add(new NavigationModel { Link = Url.Action("Index", "Employee"), Title = "Dashboard", Icon = "fa fa-plus", Class = "active" }); model.SideNavModels.Add(new NavigationModel { Link = Url.Action("Logout", "Security"), Title = "Sign Out", Icon = "fa fa-plus", Class = "active" }); #endregion var serviceId = Request .Params .GetValues("id")[0]; var requestId = int.Parse(serviceId); var dbServiceRequest = await WeedHackersContext .ServiceRequests .Include(ct => ct.Customer.CustomerType) .Include(s => s.Service) .Include(d => d.Service.Department) .SingleAsync(s => s.Id == requestId); dbServiceRequest.UnitQuantity = model.ServiceRequest.ServiceRequest.UnitQuantity; model.ServiceRequest.ServiceRequest = dbServiceRequest; return(View(model)); }
public JsonResult AddInspection(InspectionModel model) { var user = User.Identity.Name; var files = Request.Files; var login = AccountService.GetLoginByEmail(user); if (ModelState.IsValid) { var result = TenantService.AddInspection(model, login, Request.Files); if (result.IsSuccess) { return(Json(new { Success = true, Message = "Sucessfully Replied to the Property Owner's Request", Posted = true })); } else { return(Json(new { Success = false, ErrorMsg = result.ErrorMessage })); } } return(Json(new { Success = false, ErrorMsg = "Invalid fields" })); }
// api/<controller>/FindInspections public IHttpActionResult FindInspectionList(int pageNo = 1, int pageLength = 15, string searchQuery = null) { var inspectionList = new List<ClsInspection>(); var inspectionModel = new InspectionModel(); inspectionModel.PageNo = pageNo; inspectionModel.PageLength = pageLength; int startIndex = (pageNo - 1) * pageLength; var inspections = new List<Inspection>(); if (!string.IsNullOrWhiteSpace(searchQuery)) { inspectionModel.TotalRecords = db.Inspections.Count(x => x.Active == true && x.Deleted == false && x.Associate.Name.Contains(searchQuery)); inspections = db.Inspections.Where(x => x.Active && x.Deleted == false && x.Associate.Name.Contains(searchQuery)).OrderByDescending(inspection => inspection.Id) .Skip(startIndex) .Take(inspectionModel.PageLength).ToList(); } else { inspectionModel.TotalRecords = db.Inspections.Count(x => x.Active == true && x.Deleted == false); inspections = db.Inspections.Where(x => x.Active && x.Deleted == false).OrderByDescending(inspection => inspection.Id) .Skip(startIndex) .Take(inspectionModel.PageLength).ToList(); } foreach (var inspection in inspections) { var objInspection = new ClsInspection(); objInspection.AssociateName = inspection.Associate.Name; objInspection.AssociateEmail = inspection.Associate.Email; objInspection.VehicleName = string.Format("{0} - {1} - {2}", inspection.Vehicle.Make, inspection.Vehicle.Model, inspection.Vehicle.Registration); objInspection.VehicleId = inspection.VehicleId; objInspection.AssociateId = inspection.AssociateId; objInspection.Id = inspection.Id; objInspection.InspectionDueDate = inspection.InspectionDueDate; inspectionList.Add(objInspection); } inspectionModel.InspectionList = inspectionList; return Ok(inspectionModel); }
public async Task <IHttpActionResult> Post(int apiaryId, int hiveId, InspectionModel inspectionModel) { if (!ModelState.IsValid) { return(BadRequest("Inspection Model is not valid")); } try { using (var context = new BeeAppContext()) { if (await _ensurer.EnsureHiveBelongsToApiary(context, apiaryId, hiveId, _applicationUserId)) { context.Inspections.Add(new Inspection { Date = inspectionModel.Date, Name = inspectionModel.Name, Strength = inspectionModel.Strength, Temper = inspectionModel.Temper, Disease = inspectionModel.Disease, FramesBees = inspectionModel.FramesBees, FramesHoney = inspectionModel.FramesHoney, FramesHoneySupers = inspectionModel.FramesHoneySupers, Drones = inspectionModel.Drones, DroneCells = inspectionModel.DroneCells, HiveId = hiveId }); // Save context.SaveChanges(); } } } catch (Exception ex) { return(BadRequest(ex.Message)); } // Return return(Ok(inspectionModel)); }
public ActionResult Create(int id = 0) { InspectionDetail inspectionDetail = new InspectionDetail(); if (id > 0) { inspectionDetail = inspectionRepository.GetInspectionDetailById(id); } InspectionModel inspectionModel = new InspectionModel { ID = inspectionDetail.ID, DateOfInsp = inspectionDetail.DateOfInsp, PurposeOfInsp = inspectionDetail.PurposeOfInsp, InspectorName = inspectionDetail.InspectorName, InspectorDesg = inspectionDetail.InspectorDesg, InspectorAdrs = inspectionDetail.InspectorAdrs, Report = inspectionDetail.Report }; return(View(inspectionModel)); }
/// <summary> /// 由于上级平台对接程序设计的Remoting缺陷 /// 因此需要重新编写一次查岗应答消息体 /// </summary> /// <param name="msgID">查岗消息ID</param> /// <param name="replyContent">应答内容</param> /// <param name="data">查岗消息对象</param> /// <returns></returns> private byte[] BuildReplyContentBytes(UInt32 msgID, string replyContent, InspectionModel data) { //查岗应答内容 byte[] byteText = Encoding.GetEncoding("GBK").GetBytes(replyContent.Trim()); //查岗应答消息体 //子业务类型标识2+后续数据长度4+查岗对象的类型1+查岗对象的ID12+信息ID4+数据长度4+应答内容 byte[] clientSend = new byte[27 + byteText.Length]; //子业务类型标识 开始0 结束1 clientSend[0] = 0x13; clientSend[1] = 0x01; //后续数据长度 开始2 结束5 byte[] checkObject = GetBigEndianBytes4(21 + byteText.Length); checkObject.CopyTo(clientSend, 2); //对象类型 开始6 结束6 clientSend[6] = Convert.ToByte(data.ObjType); //查岗对象的ID 开始7 结束18 byte[] B12 = new byte[12]; B12 = Encoding.GetEncoding("GBK").GetBytes(data.ObjID); B12.CopyTo(clientSend, 7); // 信息ID 开始19 结束22 byte[] byteSendId = GetBigEndianBytes4(msgID); byteSendId.CopyTo(clientSend, 19); // 数据长度 开始23 结束26 byte[] sendTextLen = GetBigEndianBytes4(byteText.Length); sendTextLen.CopyTo(clientSend, 23); //应答内容 开始27 byteText.CopyTo(clientSend, 27); return(clientSend); }
public ActionResult Create(InspectionModel inspectionModel) { try { InspectionDetail inspectionDetail = new InspectionDetail { ID = inspectionModel.ID, DateOfInsp = inspectionModel.DateOfInsp, PurposeOfInsp = inspectionModel.PurposeOfInsp, InspectorName = inspectionModel.InspectorName, InspectorDesg = inspectionModel.InspectorDesg, InspectorAdrs = inspectionModel.InspectorAdrs, Report = inspectionModel.Report }; if (ModelState.IsValid) { if (inspectionDetail.ID > 0) { inspectionRepository.UpdateInspectionDetail(inspectionDetail); } else { inspectionRepository.InsertInspectionDetail(inspectionDetail); } } else { return(View(inspectionModel)); } return(RedirectToAction("Index")); } catch (Exception) { return(View(inspectionModel)); } }
public async Task <ActionResult> SendQuote(InspectionModel model) { EmailHelper send = new EmailHelper(); try { var dbServiceRequest = await WeedHackersContext .ServiceRequests .Include(ct => ct.Customer.CustomerType) .Include(ct => ct.Customer.User) .Include(s => s.Service) .Include(d => d.Service.Department) .Include(d => d.ServiceAdvisor.User) .Include(ss => ss.ServiceRequestStatusUpdates.Select(srsu => srsu.ServiceStatus)) .SingleAsync(s => s.Id == model.ServiceRequest.ServiceRequest.Id); double subtotal = dbServiceRequest.Service.PricePerUnit * (double)model.ServiceRequest.ServiceRequest.UnitQuantity; double Total = subtotal * 1.14; dbServiceRequest.UnitQuantity = model.ServiceRequest.ServiceRequest.UnitQuantity; var serviceStatus = await WeedHackersContext.ServiceStatuses.SingleAsync(ss => ss.Name == "Inspected"); ServiceRequestStatusUpdate serviceRequestStatusUpdate = new ServiceRequestStatusUpdate { ServiceRequestId = dbServiceRequest.Id, ServiceStatusId = serviceStatus.Id, Message = "Service Request has been Inspected." }; WeedHackersContext.ServiceRequestStatusUpdates.Add(serviceRequestStatusUpdate); await WeedHackersContext.SaveChangesAsync(); var emailRequest = new EmailQuoteModel(); emailRequest.Email = dbServiceRequest.ServiceAdvisor.User.Email; emailRequest.QuotationNumber = dbServiceRequest.Id.ToString(); emailRequest.ServiceType = dbServiceRequest.Service.ServiceName; emailRequest.Tell = dbServiceRequest.ServiceAdvisor.User.PhoneNumber; emailRequest.UnitQuantity = dbServiceRequest.UnitQuantity.ToString(); emailRequest.UnitPrice = dbServiceRequest.Service.PricePerUnit.ToString("R0.00"); emailRequest.UnitSubtotal = subtotal.ToString("R0.00"); emailRequest.UnitTotal = Total.ToString("R0.00"); emailRequest.EmailFormModel = new EmailFormModel { Recipient = dbServiceRequest.Customer.User.Email, Message = "" }; await send.SendQuotationEmail(emailRequest); FlashMessage.Confirmation("Inspection Complete", "Quote of inspection has been sent to the customer."); return(RedirectToAction("Index", "Employee")); } catch (Exception) { FlashMessage.Danger("Inspection Error", "There was a problem processing the inspection."); return(View("Index")); } }