public static async Task <string> TrackInfo(string token, string employeeId, string controllerName, string title, int id, string type) { var model = new TrackingInfoModel() { EmployeeId = employeeId, ModuleName = controllerName,// ControllerContext.ActionDescriptor.ControllerName, WorkDescription = type + ":-" + "Id:-" + id + ", Title:-" + title }; var response = await ApiClientFactory.Instance.SaveTackingInfo(token, model); return(Convert.ToString(response.StatusCode)); }
public async Task <DbStatusResult> AddTrackingInfo(TrackingInfoModel entity) { var cmd = new DbStatusCommand(); await ExecuteSQLWithParams("[dbo].AddTrackingInfo", GetJsonParam("@TrackingInfo", entity), cmd.IdParam, cmd.StatusParam, cmd.MessageParam); return(cmd.StatusResult); }
public async Task <ResponseModel> SaveTackingInfo(string token, TrackingInfoModel model) { try { string attachmentstring = JsonConvert.SerializeObject(model); var httpContent = new StringContent(attachmentstring, Encoding.UTF8, "application/json"); var requestUrl = CreateRequestUri(string.Format(System.Globalization.CultureInfo.InvariantCulture, "api/TrackingInfo/AddTrackingInfo")); return(await PostAsync <ResponseModel>(requestUrl, httpContent)); } catch (Exception e) { throw; } }
public async Task <ActionResult <ResponseModel> > AddTrackingInfo([FromBody] TrackingInfoModel trackingInfo) { var model = new ResponseModel(); var result = await _dataContext.AddTrackingInfo(trackingInfo); if (!result.Status) { model.StatusCode = 404; model.Message = result.Message; } else { model.StatusCode = 200; var objtrackingList = await _dataContext.GetAllTrackingInfoListByRequest(string.Empty, string.Empty, string.Empty, 0, 1000).ToListAsync(); if (objtrackingList != null) { model.ResponseObject = objtrackingList; } } return(model); }
public void Post(TrackingInfoModel model) { if (model.meta != null && model.meta.code == 200) { if (model.data == null) { return; } if (model.data.origin_info != null && model.data.status != null && model.data.origin_info.trackinfo != null) { using (DBContainer dbContext = new DBContainer()) { DbSet <Spm_ExpressInfo> dbSet0 = dbContext.Set <Spm_ExpressInfo>(); DbSet <Spm_TracesInfo> dbSet1 = dbContext.Set <Spm_TracesInfo>(); Spm_ExpressInfo exInfo = dbSet0.Where(o => o.TrackingNumber == model.data.tracking_number).FirstOrDefault(); if (exInfo != null) { switch (model.data.status) { case "notfound": exInfo.State = "0"; break; case "transit": case "pickup": case "undelivered": case "expired": exInfo.State = "2"; break; case "delivered": exInfo.State = "3"; break; case "exception": exInfo.State = "4"; break; default: break; } IQueryable <Spm_TracesInfo> ti = dbSet1.Where(t => t.ExInfoId == exInfo.Id).OrderByDescending(a => a.AcceptTime); foreach (var item in model.data.origin_info.trackinfo) { if (ti.Count() > 0) { if ((item.Date > ti.First().AcceptTime)) { Spm_TracesInfo m = new Spm_TracesInfo() { Id = ResultHelper.NewId, ExInfoId = exInfo.Id, AcceptTime = item.Date, AcceptStation = item.StatusDescription + ";" + item.Details, }; dbSet1.Add(m); } } else { Spm_TracesInfo m = new Spm_TracesInfo() { Id = ResultHelper.NewId, ExInfoId = exInfo.Id, AcceptTime = item.Date, AcceptStation = item.StatusDescription + ";" + item.Details, }; dbSet1.Add(m); } } } dbContext.SaveChanges(); } } } }