Ejemplo n.º 1
0
        public IHttpActionResult FindTestimonial(int id)
        {
            Testimonial testimonial = db.Testimonials.Find(id);

            if (testimonial == null)
            {
                return(NotFound());
            }
            TestimonialDto NewTestimonial = new TestimonialDto
            {
                testimonial_Id      = testimonial.testimonial_Id,
                testimonial_Content = testimonial.testimonial_Content,
                first_Name          = testimonial.first_Name,
                last_Name           = testimonial.last_Name,
                email         = testimonial.email,
                phone_Number  = testimonial.phone_Number,
                Has_Pic       = testimonial.Has_Pic,
                Pic_Extension = testimonial.Pic_Extension,
                posted_Date   = testimonial.posted_Date,
                Approved      = testimonial.Approved,
                Id            = testimonial.Id
            };

            return(Ok(NewTestimonial));
        }
        public IHttpActionResult FindTestimonialsForDepartment(int id)
        {
            List <Testimonial> testimonials = db.Testimonials
                                              .Where(t => t.Departments.Any(d => d.DepartmentId == id))
                                              .ToList();

            List <TestimonialDto> testimonialDtos = new List <TestimonialDto> {
            };

            foreach (var Testimonial in testimonials)
            {
                TestimonialDto NewTestimonial = new TestimonialDto
                {
                    testimonial_Id      = Testimonial.testimonial_Id,
                    testimonial_Content = Testimonial.testimonial_Content,
                    first_Name          = Testimonial.first_Name,
                    last_Name           = Testimonial.last_Name,
                    email         = Testimonial.email,
                    phone_Number  = Testimonial.phone_Number,
                    Has_Pic       = Testimonial.Has_Pic,
                    Pic_Extension = Testimonial.Pic_Extension,
                    posted_Date   = Testimonial.posted_Date,
                    Approved      = Testimonial.Approved
                };
                testimonialDtos.Add(NewTestimonial);
            }
            return(Ok(testimonialDtos));
        }
        public void update(TestimonialDto testimonial_dto)
        {
            try
            {
                _transactionManager.beginTransaction();


                Testimonial testimonial = _testimonialRepo.getById(testimonial_dto.testimonial_id);

                string oldImage = testimonial.image_name;

                _testimonialMaker.copy(ref testimonial, testimonial_dto);

                _testimonialRepo.update(testimonial);

                if (!string.IsNullOrWhiteSpace(testimonial_dto.image_name))
                {
                    if (!string.IsNullOrWhiteSpace(oldImage))
                    {
                        deleteImage(oldImage);
                    }
                }
                _transactionManager.commitTransaction();
            }
            catch (Exception)
            {
                _transactionManager.rollbackTransaction();
                throw;
            }
        }
Ejemplo n.º 4
0
        public ActionResult ApproveConfirm(int id)
        {
            string url = "testimonialdata/findtestimonial/" + id;
            HttpResponseMessage res = client.GetAsync(url).Result;

            if (res.IsSuccessStatusCode)
            {
                TestimonialDto TestimonialDto = res.Content.ReadAsAsync <TestimonialDto>().Result;
                return(View(TestimonialDto));
            }
            return(RedirectToAction("Error"));
        }
 public void copy(ref Testimonial testimonial, TestimonialDto testimonial_dto)
 {
     testimonial.testimonial_id          = testimonial_dto.testimonial_id;
     testimonial.person_name             = testimonial_dto.person_name.Trim();
     testimonial.statement               = testimonial_dto.statement.Trim();
     testimonial.designation             = testimonial_dto.designation.Trim();
     testimonial.associated_company_name = testimonial_dto.associated_company_name.Trim();
     if (!string.IsNullOrWhiteSpace(testimonial_dto.image_name))
     {
         testimonial.image_name = testimonial_dto.image_name;
     }
     testimonial.is_visible = testimonial_dto.is_visible;
 }
 public IActionResult edit(long testimonial_id)
 {
     try
     {
         var            testimonial = _testimonialRepo.getById(testimonial_id);
         TestimonialDto dto         = _mapper.Map <TestimonialDto>(testimonial);
         return(View(dto));
     }
     catch (Exception ex)
     {
         AlertHelper.setMessage(this, ex.Message, messageType.error);
         return(RedirectToAction("index"));
     }
 }
        public async Task <IActionResult> Create([FromBody] TestimonialDto dto)
        {
            _logger.LogInformation("Create Executing..");
            if (!ModelState.IsValid)
            {
                var message = ModelState.GetModelErrors().Select(x => new Messages
                {
                    Code        = "XX",
                    Description = x
                }).ToList();
                return(Okay(new ServiceResponse(false, message)));
            }
            var entity = _mapper.Map <TestimonialDto, Testimonial>(dto);

            var serviceResult = await _service.CreateAsync(entity);

            return(Okay(serviceResult));
        }
        public void save(TestimonialDto testimonial_dto)
        {
            try
            {
                _transactionManager.beginTransaction();

                Testimonial testimonial = new Testimonial();
                _testimonialMaker.copy(ref testimonial, testimonial_dto);

                _testimonialRepo.insert(testimonial);

                _transactionManager.commitTransaction();
            }
            catch (Exception)
            {
                _transactionManager.rollbackTransaction();
                throw;
            }
        }
        public async Task <IActionResult> Edit([FromBody] TestimonialDto dto)
        {
            _logger.LogInformation("Edit post Executing..");

            if (!ModelState.IsValid)
            {
                var message = ModelState.GetModelErrors().Select(x => new Messages
                {
                    Code        = "XX",
                    Description = x
                }).ToList();
                return(Okay(new ServiceResponse(false, message)));
            }

            var detailResp = _service.Detail(dto.Id);

            if (!detailResp.Status)
            {
                return(Okay(new ServiceResponse <TestimonialDto>(detailResp.Status)
                {
                    Data = dto,
                    Messages = detailResp.Messages
                }));
            }
            var entity = detailResp.Data;

            entity.Address      = dto.Address;
            entity.Descriptions = dto.Descriptions;
            entity.Title        = dto.Title;
            entity.Email        = dto.Email;
            entity.IsActive     = dto.IsActive;


            var serviceResult = await _service.EditAsync(entity);

            if (serviceResult.Status)
            {
                return(Okay(serviceResult));
            }

            return(Okay(serviceResult));
        }
Ejemplo n.º 10
0
        public IHttpActionResult FindTestimonial(int id)
        {
            Testimonial Testimonial = db.testimonials.Find(id);

            if (Testimonial == null)
            {
                return(NotFound());
            }

            TestimonialDto TestimonialDto = new TestimonialDto
            {
                testimonialId = Testimonial.testimonialId,
                creationDate  = Testimonial.creationDate,
                testimonial   = Testimonial.testimonial,
                approved      = Testimonial.approved,
                UserId        = Testimonial.UserId
            };

            return(Ok(TestimonialDto));
        }
Ejemplo n.º 11
0
        public IHttpActionResult GetTestimonials()
        {
            List <Testimonial>    Testimonials    = db.testimonials.ToList();
            List <TestimonialDto> TestimonialDtos = new List <TestimonialDto> {
            };

            foreach (var Testimonial in Testimonials)
            {
                TestimonialDto newTestimonial = new TestimonialDto
                {
                    testimonialId = Testimonial.testimonialId,
                    creationDate  = Testimonial.creationDate,
                    testimonial   = Testimonial.testimonial,
                    approved      = Testimonial.approved,
                    UserId        = Testimonial.UserId
                };
                TestimonialDtos.Add(newTestimonial);
            }

            return(Ok(TestimonialDtos));
        }
 public IActionResult edit(TestimonialDto testimonial_dto, IFormFile file = null)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (file != null)
             {
                 string fileName = testimonial_dto.person_name;
                 testimonial_dto.image_name = _fileHelper.saveImageAndGetFileName(file, fileName);
             }
             _testimonialService.update(testimonial_dto);
             AlertHelper.setMessage(this, "Testimonial updated successfully.");
             return(RedirectToAction("index"));
         }
     }
     catch (Exception ex)
     {
         AlertHelper.setMessage(this, ex.Message, messageType.error);
     }
     return(View(testimonial_dto));
 }
        public IActionResult add(TestimonialDto model, IFormFile file = null)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (file != null)
                    {
                        string fileName = model.person_name;
                        model.image_name = _fileHelper.saveImageAndGetFileName(file, fileName);
                    }
                    _testimonialService.save(model);
                    AlertHelper.setMessage(this, "Testimonial saved successfully.", messageType.success);
                    return(RedirectToAction("index"));
                }
            }
            catch (Exception ex)
            {
                AlertHelper.setMessage(this, ex.Message, messageType.error);
            }

            return(View(model));
        }
        public ActionResult DeleteConfirm(int DepartmentId, int TestimonialId)
        {
            TestimonialDetails  Testimonial_Details = new TestimonialDetails();
            string              url      = "TestimonialData/FindTestimonial/" + TestimonialId;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                TestimonialDto Testimonial = response.Content.ReadAsAsync <TestimonialDto>().Result;
                Testimonial_Details.TestimonialDto = Testimonial;

                url      = "DepartmentData/FindDepartment/" + DepartmentId;
                response = client.GetAsync(url).Result;

                DepartmentsDto Department = response.Content.ReadAsAsync <DepartmentsDto>().Result;
                Testimonial_Details.DepartmentDto = Department;

                return(View(Testimonial_Details));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
 public static Testimonial ToEntity(this TestimonialDto model)
 {
     return(model.MapTo <TestimonialDto, Testimonial>());
 }
Ejemplo n.º 16
0
 public TestimonialDtoBuilder()
 {
     _testimonialDto = WithDefaults();
 }