public IObjResult <Commenters> GetById(int id, AutUserInfo userInfo) { string _resultMessage = string.Empty; int _code = StaticValues.InfoCode; bool _resultval = false; Commenters _resultentity = null; try { _resultentity = _repos.Get(x => x.Id == id && x.Active && !x.Deleted); if (_resultentity != null) { _code = StaticValues.SuccessCode; _resultMessage = StaticValues.SuccessMessage; _resultval = true; } else { _code = StaticValues.ErrorNullObjCode; _resultMessage = StaticValues.ErrorNullObjMessage; } } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "GetById", "CommentersManager", Enum.GetName(typeof(LayerInfo), 2), "", userInfo.ClientIp, userInfo.UsrId); _code = StaticValues.ErrorCode; _resultMessage = StaticValues.ErrorMessage; } return(new ObjResult <Commenters>(_resultval, _resultMessage, _code, _resultentity)); }
public IResult Delete(int id, AutUserInfo userInfo) { string _resultMessage = string.Empty; int _code = StaticValues.InfoCode; bool _resultval = false; try { Commenters model = _repos.Get(x => x.Id == id); if (model != null) { model.Active = false; model.Deleted = true; model.ModifiedDate = DateTime.Now; model.ModifiedUserId = userInfo.UsrId; _repos.Update(model); _code = StaticValues.SuccessCode; _resultMessage = StaticValues.SuccessMessage; _resultval = true; } else { _code = StaticValues.ErrorNullObjCode; _resultMessage = StaticValues.ErrorNullObjMessage; } } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "Delete", "CommentersManager", Enum.GetName(typeof(LayerInfo), 2), "", userInfo.ClientIp, userInfo.UsrId); _code = StaticValues.ErrorCode; _resultMessage = StaticValues.ErrorMessage; } return(new Result(_resultval, _resultMessage, _code)); }
public IObjResult <Commenters> GetCommenter(int id) { AutUserInfo userInfo = _httpContext.HttpContext.Session.GetObject <AutUserInfo>("UserInfo"); string resultmessage = StaticValues.ErrorMessage; int resultcode = StaticValues.ErrorCode; bool resultval = false; Commenters resultobj = null; try { if (!_memcache.TryGetValue <Commenters>("Commenter" + id, out resultobj)) { var result = _writer.GetById(id, userInfo); resultcode = result.ResultCode; resultmessage = result.Message; resultval = result.IsSuccess; resultobj = result.Object; if (resultval) { _memcache.Set <Commenters>("Commenter" + id, resultobj); } } else { resultcode = StaticValues.SuccessCode; resultmessage = StaticValues.SuccessMessage; resultval = true; } } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "GetCommenter", "CommenterController", Enum.GetName(typeof(LayerInfo), 1), "", userInfo.ClientIp, userInfo.UsrId); } return(new ObjResult <Commenters>(resultval, resultmessage, resultcode, resultobj)); }
public IResult UpdateCommenter([FromBody] Commenters model) { AutUserInfo userInfo = _httpContext.HttpContext.Session.GetObject <AutUserInfo>("UserInfo"); string resultmessage = StaticValues.ErrorMessage; int resultcode = StaticValues.ErrorCode; bool resultval = false; try { var result = _writer.Update(model, userInfo); resultcode = result.ResultCode; resultmessage = result.Message; resultval = result.IsSuccess; } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "UpdateCommenter", "CommenterController", Enum.GetName(typeof(LayerInfo), 1), _httpContext.HttpContext.Request.Path, userInfo.ClientIp, userInfo.UsrId); } return(new Result(resultval, resultmessage, resultcode)); }
public IResult Add(Commenters model, AutUserInfo userInfo) { string _resultMessage = string.Empty; int _code = StaticValues.InfoCode; bool _resultval = false; try { _repos.Add(model); _code = StaticValues.SuccessCode; _resultMessage = StaticValues.SuccessMessage; _resultval = true; } catch (Exception ex) { _logs.Add(userInfo.SessId, ex.ToString(), "Add", "CommentersManager", Enum.GetName(typeof(LayerInfo), 2), "", userInfo.ClientIp, userInfo.UsrId); _code = StaticValues.ErrorCode; _resultMessage = StaticValues.ErrorMessage; _resultval = false; } return(new Result(_resultval, _resultMessage, _code)); }