public IActionResult Update(MonthlyPlanDto monthlyPlanDto) { var isOver = _monthlyPlanService.IsOver(monthlyPlanDto.Id); if (!isOver.Success) { return(BadRequest(isOver.Message)); } var planExist = _monthlyPlanService.PlanExist(monthlyPlanDto); if (!planExist.Success) { return(BadRequest(planExist.Message)); } var result = _monthlyPlanService.Update(monthlyPlanDto); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }
public IResult PlanExist(MonthlyPlanDto monthlyPlanDto) { var userPlans = _monthlyPlanDal.GetList(w => w.UserId.Equals(UserId) && w.Year.Equals(monthlyPlanDto.Year) && w.Month.Equals(monthlyPlanDto.Month) && !w.Id.Equals(monthlyPlanDto.Id)); if (userPlans.Any()) { return(new ErrorResult(Messages.MonthlyPlanExist)); } return(new SuccessResult()); }
public IResult Update(MonthlyPlanDto monthlyPlanDto) { var plan = _monthlyPlanDal.Get(w => w.Id == monthlyPlanDto.Id); plan.Description = monthlyPlanDto.Description; plan.ImportanceTypeId = monthlyPlanDto.ImportanceTypeId; plan.Month = monthlyPlanDto.Month; plan.Name = monthlyPlanDto.Name; plan.Year = monthlyPlanDto.Year; _monthlyPlanDal.Update(plan); return(new SuccessResult(Messages.MonthlyPlanUpdated)); }
public IResult Add(MonthlyPlanDto monthlyPlanDto) { _monthlyPlanDal.Add(new MonthlyPlan { UserId = UserId, Description = monthlyPlanDto.Description, ImportanceTypeId = monthlyPlanDto.ImportanceTypeId, Month = monthlyPlanDto.Month, Name = monthlyPlanDto.Name, Year = monthlyPlanDto.Year }); return(new SuccessResult(Messages.MonthlyPlanAdded)); }
public IActionResult Add(MonthlyPlanDto monthlyPlanDto) { monthlyPlanDto.Id = 0; var planExist = _monthlyPlanService.PlanExist(monthlyPlanDto); if (!planExist.Success) { return(BadRequest(planExist.Message)); } var result = _monthlyPlanService.Add(monthlyPlanDto); if (result.Success) { return(Ok(result.Message)); } return(BadRequest(result.Message)); }