Exemplo n.º 1
0
        // PUT: api/Banner/5
        public HttpResponseMessage Put([FromBody] ProjectImage projectImage)
        {
            try
            {
                if (projectImage.Thumbnail.ToString() != "")
                {
                    if (projectImage.Thumbnail.ToString().Contains("/Content"))
                    {
                        projectImage.Thumbnail = projectImage.Thumbnail;
                    }
                    else
                    {
                        projectImage.Thumbnail = "/Content/UploadFiles/images/images/thumb_" + projectImage.Thumbnail;
                    }
                }
                else
                {
                    projectImage.Thumbnail = "/Content/images/No_image_available.png";
                }

                _projectImageService.Update(projectImage);



                var responseMessage = new { message = "Chỉnh sửa thành công!" };
                return(Request.CreateResponse(HttpStatusCode.OK, responseMessage));
            }
            catch (Exception)
            {
                var responseMessage = new { message = "Lỗi! Vui lòng thử lại sau!" };
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, responseMessage));

                throw;
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage Put(int id, [FromBody] ProjectImage projectImageModel)
        {
            try
            {
                if (projectImageModel.ResourceUrl.ToString() != "")
                {
                    if (projectImageModel.ResourceUrl.ToString().Contains("/Content") &&
                        projectImageModel.Thumbnail.ToString().Contains("/Content"))
                    {
                        projectImageModel.ResourceUrl = projectImageModel.ResourceUrl;
                        projectImageModel.Thumbnail   = projectImageModel.Thumbnail;
                    }
                    else
                    {
                        projectImageModel.ResourceUrl = "/Content/UploadFiles/images/images/" +
                                                        projectImageModel.ResourceUrl;
                        projectImageModel.Thumbnail = "/Content/UploadFiles/images/images/thumb_" +
                                                      projectImageModel.ResourceUrl;
                    }
                }
                else
                {
                    projectImageModel.ResourceUrl = "/Content/images/No_image_available.png";
                    projectImageModel.Thumbnail   = "/Content/images/No_image_available.png";
                }


                projectImageModel.Status           = true;
                projectImageModel.ModifiedDateTime = DateTime.Now;
                projectImageModel.ModifiedById     = _userId;

                _projectImageService.Update(projectImageModel);


                foreach (var projectImageMapping in projectImageModel.ProjectImageMappings)
                {
                    _projectImageMappingService.Update(projectImageMapping);
                }

                var responseMessage = new { message = "Chỉnh sửa thành công!" };
                return(Request.CreateResponse(HttpStatusCode.OK, responseMessage));
            }
            catch (Exception)
            {
                var responseMessage = new { message = "Lỗi! Vui lòng thử lại sau!" };
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, responseMessage));

                throw;
            }
        }
Exemplo n.º 3
0
        // PUT: api/Banner/5
        public HttpResponseMessage Put([FromBody] Project project)
        {
            try
            {
                project.ModifiedById     = _userId;
                project.ModifiedDateTime = DateTime.Now;

                if (project.ProjectImages.Count() > 0)
                {
                    foreach (var projectImageModel in project.ProjectImages)
                    {
                        projectImageModel.ModifiedById     = _userId;
                        projectImageModel.ModifiedDateTime = DateTime.Now;
                        _projectImageService.Update(projectImageModel);
                    }
                }

                if (project.News.Count() > 0)
                {
                    foreach (var projectNew in project.News)
                    {
                        projectNew.ModifiedById     = _userId;
                        projectNew.ModifiedDateTime = DateTime.Now;
                        _newsService.Update(projectNew);

                        foreach (var projectNewsMapping in projectNew.NewsMappings)
                        {
                            projectNewsMapping.ModifiedById     = _userId;
                            projectNewsMapping.ModifiedDateTime = DateTime.Now;
                            _newsMappingService.Update(projectNewsMapping);
                        }
                    }
                }

                _projectService.Update(project);
                var responseMessage = new { message = "Chỉnh sửa thành công!" };
                return(Request.CreateResponse(HttpStatusCode.OK, responseMessage));
            }
            catch (Exception)
            {
                var responseMessage = new { message = "Lỗi! Vui lòng thử lại sau!" };
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, responseMessage));

                throw;
            }
        }