Beispiel #1
0
        public async Task <BookreviewRequestClass> EditReview(Bookreview p)
        {
            var returnVal = new BookreviewRequestClass();

            var y = await repoBookreview.Get(a => a.id == p.id);

            if (y != null)
            {
                if (
                    y.surname == p.surname &&
                    y.othernames == p.othernames &&
                    y.nationality == p.nationality &&
                    y.address == p.address &&
                    y.email == p.email &&
                    y.title == p.title &&
                    y.datecreated == p.datecreated

                    )
                {
                    returnVal.ErrorCode = -1;
                    returnVal.ErrorText = "No change is made";
                }
                else
                {
                    y.surname     = p.surname;
                    y.othernames  = p.othernames;
                    y.nationality = p.nationality;
                    y.address     = p.address;
                    y.email       = p.email;
                    y.title       = p.title;
                    y.datecreated = p.datecreated;



                    repoAuthors.Update(y);
                    try
                    {
                        var retV = await unitOfWork.Commit(Convert.ToInt16(p.userid)) > 0 ? true : false;

                        if (retV)
                        {
                            returnVal.ErrorCode = 0;
                            returnVal.ErrorText = "Record 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);
        }
Beispiel #2
0
        public async Task <BookreviewRequestClass> AddBookReview(Bookreview p)
        {
            var returnVal = new BookreviewRequestClass();
            var review    = await repoBookreview.Get(l => l.userid == p.userid);

            if (review != null)
            {
                returnVal.ErrorCode = -2;
                returnVal.ErrorText = "You already Reviewed This Book!!";

                return(returnVal);
            }

            p.reviewdate = DateTime.Now;
            p.userid     = p.userid;
            repoBookreview.Add(p);
            try
            {
                var retV = await unitOfWork.Commit(Convert.ToUInt16(p.userid)) > 0 ? true : false;

                if (retV)
                {
                    returnVal.ErrorCode = 0;
                    returnVal.ErrorText = "Record Added 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);
        }