예제 #1
0
        public async Task <IActionResult> AddHome([FromForm] HomeContentDTO request)
        {
            try
            {
                if (String.IsNullOrEmpty(request.TitleEN))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "English Title Not Found!"));
                }
                else if (String.IsNullOrEmpty(request.TitleAR))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "Arabic Title Not Found!"));
                }
                else if (String.IsNullOrEmpty(request.DescriptionEN))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "English Description Not Found!"));
                }
                else if (String.IsNullOrEmpty(request.DescriptionAR))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "Arabic Description Not Found!"));
                }
                else if (String.IsNullOrEmpty(request.Video))
                {
                    return(StatusCode((int)System.Net.HttpStatusCode.BadRequest, "Video Not Found!"));
                }
                else
                {
                    var result = await _homeRepo.AddAsync(request);

                    if (result != null)
                    {
                        return(Ok(result));
                    }
                    else
                    {
                        return(NoContent());
                    }
                }
            }
            catch (Exception ex)
            {
                return(StatusCode((int)System.Net.HttpStatusCode.InternalServerError, ex.Message));
            }
        }