public async Task <IActionResult> Post([FromBody] Author value)
        {
            if (value == null)
            {
                return(BadRequest("Author is empty"));
            }
            await authorsRepository.Add(value);

            return(Ok("Author created"));
        }
Ejemplo n.º 2
0
        public IActionResult Create([FromBody] Author newAuthor)
        {
            if (newAuthor == null)
            {
                return(BadRequest());
            }

            _authorsRepository.Add(newAuthor);

            return(CreatedAtRoute("GetAuthorById", new { authorId = newAuthor.Id }, newAuthor));
        }
Ejemplo n.º 3
0
        public async Task <AuthorsRequestClass> AddAuthor(Authors p)
        {
            var returnVal = new AuthorsRequestClass();
            var actType   = await repoAuthors.Get(l => l.surname == p.surname);

            if (actType != null)
            {
                returnVal.ErrorCode = -2;
                returnVal.ErrorText = "Author already Exists!!";

                return(returnVal);
            }

            p.datecreated = DateTime.Now;
            p.userid      = p.userid;
            repoAuthors.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);
        }
Ejemplo n.º 4
0
 public async Task AddAndSave(FinalProject.Models.Authors author)
 {
     _authorRepo.Add(author);
     await _authorRepo.Save();
 }
Ejemplo n.º 5
0
 // POST: api/Authors
 public int Post([FromBody] Author value)
 {
     return(authorsRepository.Add(value));
 }
Ejemplo n.º 6
0
        // POST: api/authors
        public HttpResponseMessage Post([FromBody] Author value)
        {
            int id = _authorsRepository.Add(value);

            return(Request.CreateResponse <int>(HttpStatusCode.Created, id));
        }