public IActionResult Update(DailyPlanDto dailyPlanDto)
        {
            var isOver = _dailyPlanService.IsOver(dailyPlanDto.Id);

            if (!isOver.Success)
            {
                return(BadRequest(isOver.Message));
            }

            var planExist = _dailyPlanService.PlanExist(dailyPlanDto);

            if (!planExist.Success)
            {
                return(BadRequest(planExist.Message));
            }

            var result = _dailyPlanService.Update(dailyPlanDto);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }
示例#2
0
        public IResult PlanExist(DailyPlanDto dailyPlanDto)
        {
            var userPlans = _dailyPlanDal.GetList(w => w.UserId.Equals(UserId) && w.Date.Equals(dailyPlanDto.Date) && !w.Id.Equals(dailyPlanDto.Id));

            if (userPlans.Any())
            {
                return(new ErrorResult(Messages.DailyPlanExist));
            }

            return(new SuccessResult());
        }
示例#3
0
        public IResult Update(DailyPlanDto dailyPlanDto)
        {
            var plan = _dailyPlanDal.Get(w => w.Id == dailyPlanDto.Id);

            plan.Description      = dailyPlanDto.Description;
            plan.ImportanceTypeId = dailyPlanDto.ImportanceTypeId;
            plan.Date             = dailyPlanDto.Date;
            plan.Name             = dailyPlanDto.Name;

            _dailyPlanDal.Update(plan);

            return(new SuccessResult(Messages.DailyPlanUpdated));
        }
示例#4
0
        public IResult Add(DailyPlanDto dailyPlanDto)
        {
            _dailyPlanDal.Add(new DailyPlan
            {
                UserId           = UserId,
                Description      = dailyPlanDto.Description,
                ImportanceTypeId = dailyPlanDto.ImportanceTypeId,
                Date             = dailyPlanDto.Date,
                Name             = dailyPlanDto.Name
            });

            return(new SuccessResult(Messages.DailyPlanAdded));
        }
        public IActionResult Add(DailyPlanDto dailyPlanDto)
        {
            dailyPlanDto.Id = 0;
            var planExist = _dailyPlanService.PlanExist(dailyPlanDto);

            if (!planExist.Success)
            {
                return(BadRequest(planExist.Message));
            }

            var result = _dailyPlanService.Add(dailyPlanDto);

            if (result.Success)
            {
                return(Ok(result.Message));
            }

            return(BadRequest(result.Message));
        }