public TechnicalWorksRepository() { var ctx = HttpContext.Current; if (ctx != null) { if (ctx.Cache[CacheKey] == null) { var status = new TechnicalWorks { Token = null, Status = 0, Datetime = null }; ctx.Cache[CacheKey] = status; } } }
public HttpResponseMessage Post(TechnicalWorks technicalWorks) { HttpResponseMessage response; if (authenticationRepository.CheckToken(technicalWorks.Token)) { this.technicalWorksRepository.SaveContact(technicalWorks); response = Request.CreateResponse<TechnicalWorks>(System.Net.HttpStatusCode.Accepted, technicalWorks); } else { response = Request.CreateResponse<TechnicalWorks>(System.Net.HttpStatusCode.OK, technicalWorks); } return response; }
public bool SaveContact(TechnicalWorks technicalWorks) { var ctx = HttpContext.Current; if (ctx != null) { try { technicalWorks.Token = null; ctx.Cache[CacheKey] = technicalWorks; return true; } catch (Exception ex) { Console.WriteLine(ex.ToString()); return false; } } return false; }