public Contract SaveAsync(Contract cls) { try { var headers = Request.Headers?.ToList(); if (headers == null || headers.Count <= 0) { return(null); } var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault(); if (string.IsNullOrEmpty(guid)) { return(null); } var cusGuid = Guid.Parse(guid); if (!Assistence.CheckCustomer(cusGuid)) { return(null); } db.Contracts.AddOrUpdate(cls); db.SaveChanges(); Assistence.SaveLog(cusGuid, cls.Guid, EnTemp.Contract); return(cls); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(null); } }
public IEnumerable <Scrapper> GetAllAsync() { try { var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault(); var date = Request.Headers.GetValues("date").FirstOrDefault(); var insertedDate = DateTime.Parse(date); var newDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); var distance = newDate - insertedDate; if (distance.Days > 7) { insertedDate = DateTime.Now.AddDays(-7); } if (string.IsNullOrEmpty(guid)) { return(null); } var cusGuid = Guid.Parse(guid); if (!Assistence.CheckCustomer(cusGuid)) { return(null); } insertedDate = new DateTime(insertedDate.Year, insertedDate.Month, insertedDate.Day, 0, 0, 0); return(_db.Scrapper.Where(q => q.DateM >= insertedDate).ToList()); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(null); } }
public BuildingNote SaveAsync(BuildingNote cls) { try { cls.Modified = DateTime.Now; var headers = Request.Headers?.ToList(); if (headers == null || headers.Count <= 0) { return(null); } var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault(); if (string.IsNullOrEmpty(guid)) { return(null); } var cusGuid = Guid.Parse(guid); if (!Assistence.CheckCustomer(cusGuid)) { return(null); } db.BuildingNote.AddOrUpdate(cls); db.SaveChanges(); return(cls); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(null); } }
public IEnumerable <BuildingListViewModel> GetLastList(EnRequestType type) { var list = new List <BuildingListViewModel>(); try { var headers = Request.Headers?.ToList(); if (headers == null || headers.Count <= 0) { return(null); } var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault(); if (string.IsNullOrEmpty(guid)) { return(list); } var cusGuid = Guid.Parse(guid); if (!Assistence.CheckCustomer(cusGuid)) { return(list); } list = BuildingBussines.GetAllBuildingListViewModel(cusGuid, type); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } return(list); }