public async Task <BookratingRequestClass> AddBookrating(Bookrating p) { var returnVal = new BookratingRequestClass(); p.daterated = DateTime.Now; p.userid = p.userid; repoBookrating.Add(p); try { var retV = await unitOfWork.Commit(Convert.ToUInt16(p.userid)) > 0 ? true : false; if (retV) { returnVal.ErrorCode = 0; returnVal.ErrorText = "Book Rated Succesfully"; return(returnVal); } } catch (Exception ex) { sLogUtility.SaveLog(ex.Message == null ? ex.InnerException.Message : ex.Message); returnVal.ErrorCode = -1; returnVal.ErrorText = ex.Message == null ? ex.InnerException.Message : ex.Message; return(returnVal); } return(returnVal); }
public async Task <BookratingRequestClass> EditBookrating(Bookrating p) { var returnVal = new BookratingRequestClass(); var y = await repoBookrating.Get(a => a.id == p.id); if (y != null) { if ( y.bookid == p.bookid && y.rating == p.rating && y.daterated == p.daterated && y.userid == p.userid ) { returnVal.ErrorCode = -1; returnVal.ErrorText = "No change is made"; } else { y.bookid = p.bookid; y.rating = p.rating; y.daterated = p.daterated; y.userid = p.userid; repoBookrating.Update(y); try { var retV = await unitOfWork.Commit(Convert.ToInt16(p.userid)) > 0 ? true : false; if (retV) { returnVal.ErrorCode = 0; returnVal.ErrorText = "Rating Updated Succesfully"; return(returnVal); } } catch (Exception ex) { returnVal.ErrorCode = -1; returnVal.ErrorText = ex.Message == null ? ex.InnerException.Message : ex.Message; sLogUtility.SaveLog(ex.Message == null ? ex.InnerException.Message : ex.Message); return(returnVal); } } } return(returnVal); }