public ResponseModel EditScandata(ScanDataModel tblscandata) { var contex = _httpContextAccessor.HttpContext; var res = new ResponseModel() { Status = "200", Message = "", }; var role = _userService.GetRole(int.Parse(contex.User.Identity.Name)); if (role == Constant.Users.Admin || role == Constant.Users.Superadmin) { try { var oldscandata = (from u in _context.TblScanData where u.ScanId == tblscandata.ScanId select u).FirstOrDefault(); if (oldscandata != null) { oldscandata.Uid = tblscandata.Uid; oldscandata.Payload = tblscandata.Payload; oldscandata.DataType = tblscandata.DataType; oldscandata.FileName = tblscandata.FileName; oldscandata.Status = tblscandata.Status; oldscandata.DeletedOn = null; _context.SaveChanges(); res.Data = oldscandata; } } catch (Exception ex) { res.Status = "500"; res.Message = ex.Message; } return(res); } if (role == Constant.Users.User) { try { var oldscandata = (from u in _context.TblScanData where u.ScanId == tblscandata.ScanId && u.Uid == int.Parse(contex.User.Identity.Name) select u).FirstOrDefault(); if (oldscandata != null) { oldscandata.Payload = tblscandata.Payload; oldscandata.DataType = tblscandata.DataType; oldscandata.FileName = tblscandata.FileName; oldscandata.Status = tblscandata.Status; oldscandata.DeletedOn = null; _context.SaveChanges(); res.Data = oldscandata; } } catch (Exception ex) { res.Status = "500"; res.Message = ex.Message; } return(res); } return(res); }
// Test ScanData private ScanDataModel GetAddScandata() { var x = new ScanDataModel() { Uid = 3, ScanId = "John", CreatedOn = "dsad", Payload = "vcn", DataType = "string", FileName = "ads", Status = 1 }; return(x); }
public ResponseModel ImportScanData(ScanDataModel tblscandata) { throw new NotImplementedException(); }
public ResponseModel AddScanData(ScanDataModel tblscandata) { var contex = _httpContextAccessor.HttpContext; var res = new ResponseModel() { Status = "200", Message = "", }; var role = _userService.GetRole(int.Parse(contex.User.Identity.Name)); if (role == Constant.Users.Admin || role == Constant.Users.Superadmin || role == Constant.Users.User) { try { Guid g; g = Guid.NewGuid(); var rs = _context.TblScanData.FirstOrDefault(p => p.ScanId == tblscandata.ScanId && tblscandata.ScanId != null); if (rs == null) { var x = new TblScanData { ScanId = g.ToString(), Uid = int.Parse(contex.User.Identity.Name), CreatedOn = DateTime.UtcNow, Payload = tblscandata.Payload, DataType = tblscandata.DataType, FileName = tblscandata.FileName, Status = tblscandata.Status, StationName = tblscandata.StationName, DeletedOn = null, }; _context.TblScanData.Add(x); _context.SaveChanges(); var item = new ScanDataModel { ScanId = x.ScanId, Uid = int.Parse(contex.User.Identity.Name), CreatedOn = new DateTime(x.CreatedOn.Value.Ticks).ToString("o"), Payload = x.Payload, DataType = x.DataType, FileName = x.FileName, StationName = x.StationName, Status = x.Status, }; res.Data = item; } else { res.Status = "500"; res.Message = "This scan data with id " + tblscandata.ScanId + " is existed"; } } catch (Exception ex) { res.Status = "500"; res.Message = ex.Message; } return(res); } return(res); }
public IActionResult EditScandata(ScanDataModel tblscandata) { return(Ok(_IScanDataService.EditScandata(tblscandata))); }