public async Task <IActionResult> Update(int id)
        {
            PromotionFormModel model = new PromotionFormModel();

            try
            {
                Result result = await _promotionService.UsedPromotionAsync(id);

                model.FormMessage = result.FormMessage;
                model.IsSuccess   = result.IsSuccess;
                if (model.IsSuccess)
                {
                    model.FormMessage = "İşleminiz başarılı bir şekilde gerçekleştirildi.";
                }
                return(this.Json((object)model));
            }
            catch (Exception ex)
            {
                LoggerExtensions.LogError(_logger, ex, "POST Update Error {0}", new object[1]
                {
                    id
                });
                model.FormMessage = "İşleminiz gerçekleştirilemedi.";
                return(this.Json((object)model));
            }
        }
        public IActionResult Create()
        {
            PromotionFormModel promotionFormModel = new PromotionFormModel
            {
                IsActive = true
            };

            FillPromotionFormModel(promotionFormModel);
            return(this.View((object)promotionFormModel));
        }
        public async Task <IActionResult> Create(PromotionFormModel model)
        {
            try
            {
                FillPromotionFormModel(model);
                if (!this.ModelState.IsValid)
                {
                    return(this.View((object)model));
                }
                if (!DateTime.TryParseExact(model.DueDateStr, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime result))
                {
                    model.IsSuccess   = false;
                    model.FormMessage = "Geçerli bir tarih giriniz.";
                    return(this.View((object)model));
                }
                model.DueDate = result;
                if (model.DueDate < DateTime.Today)
                {
                    model.IsSuccess   = false;
                    model.FormMessage = "Son kullanım tarihi bugünden önce olamaz.";
                    return(this.View((object)model));
                }
                PromotionDTO promotionDTO = new PromotionDTO
                {
                    IsActive  = true,
                    Message   = model.Message,
                    DueDate   = model.DueDate,
                    UserId    = model.UserId,
                    PlaceId   = model.PlaceId,
                    CreatedBy = base.CurrentUser.FullName
                };
                if (base.CurrentUser.Role == UserRole.Dealer)
                {
                    model.PlaceId = (base.CurrentUser.PlaceId ?? 0);
                }
                Result <PromotionDTO> result2 = await _promotionService.AddPromotionAsync(promotionDTO);

                model.FormMessage = result2.FormMessage;
                model.IsSuccess   = result2.IsSuccess;
                if (model.IsSuccess)
                {
                    model.FormMessage = "İşleminiz başarılı bir şekilde gerçekleştirildi.";
                }
                return(this.View((object)model));
            }
            catch (Exception ex)
            {
                LoggerExtensions.LogError(_logger, ex, "Create Error", Array.Empty <object>());
                model.IsSuccess   = false;
                model.FormMessage = "İşleminiz gerçekleştirilemedi.";
                return(this.View((object)model));
            }
        }
        private void FillPromotionFormModel(PromotionFormModel model)
        {
            if (model.DueDate == DateTime.MinValue)
            {
                model.DueDate = DateTime.Today;
            }
            if (base.CurrentUser.Role == UserRole.SuperAdmin)
            {
                model.IsSuperAdmin = true;
            }
            int?companyId = base.CurrentUser.CompanyId;

            if (base.CurrentUser.Role == UserRole.SuperAdmin)
            {
                companyId = null;
            }
            Result <List <PlaceDTO> > result = _placeService.GetAllPlaceAsync(new PlaceSearchModel
            {
                CompanyId = companyId,
                Page      = 0,
                PageSize  = 1000
            }).Result;

            if (result.IsSuccess)
            {
                model.Places = result.Data;
            }
            CompanyUserSearchModel companyUserSearchModel = new CompanyUserSearchModel
            {
                CompanyId = companyId,
                PlaceId   = base.CurrentUser.PlaceId,
                Page      = 1,
                PageSize  = 1000
            };
            Result <List <FeedbackDetailDTO> > result2 = _feedbackService.GetAllFeedbackDetailAsync(companyUserSearchModel).Result;

            if (result2.IsSuccess)
            {
                List <FeedbackDetailDTO> data = result2.Data;
                model.Users = (from o in EnumerableExtensions.Distinct <UserDTO>(from s in data.Where(delegate(FeedbackDetailDTO w)
                {
                    if (w.IsUserShare && !w.IsAnon)
                    {
                        return(w.User.Email != null);
                    }
                    return(false);
                })
                                                                                 select s.User, (Func <UserDTO, UserDTO, bool>)((UserDTO dto, UserDTO userDTO) => dto.Id == userDTO.Id))
                               orderby o.CreatedDate descending
                               select o).ToList();
            }
        }