示例#1
0
        public static EmployeeWeekOrderDto MapDto(ApplicationDbContext context, WeekPaiment weekPaiment,
                                                  WeekYearDto wyDto)
        {
            double defaultDebt;

            double.TryParse(WebConfigurationManager.AppSettings["defaultCreditValue"], out defaultDebt);

            return(new EmployeeWeekOrderDto
            {
                WeekOrderId = weekPaiment.WeekOrderMenu.Id,
                DayOrders =
                    weekPaiment.WeekOrderMenu.DayOrderMenus.Where(dom => dom.MenuForDay.WorkingDay.IsWorking)
                    .Select(OrderDayMenuDto.MapDto)
                    .ToList(),
                WeekOrderDishes = context.FactDishQuantByWeekOrderId(weekPaiment.WeekOrderMenu.Id).Result,
                WeekIsPaid = weekPaiment.WeekIsPaid,
                Balance = weekPaiment.WeekOrderMenu.User.Balance,
                WeekYear = wyDto,
                PrevWeekBalance = weekPaiment.PreviousWeekBalance,
                WeekPaiment = weekPaiment.Paiment,
                AllowDebt = defaultDebt,
                CheckDebt = weekPaiment.WeekOrderMenu.User.CheckDebt,
                DayNames = context.GetDayNames(wyDto).Result
            });
        }
        public void TestGetUserWeekOrder()
        {
            WeekYearDto wyDto = new WeekYearDto
            {
                Week = 19,
                Year = 2016
            };
            User user = _userManager.FindByName("employee");
            //WeekOrderMenu ordmenu = _weekOrderMenuService.FindByUserIdWeekYear(user.Id, wyDto);
            WeekPaiment          weekPaiment = _weekPaimentService.GetByUseridWeekYear(user.Id, wyDto);
            EmployeeWeekOrderDto model       = EmployeeWeekOrderDto.MapDto(_unitOfWork.GetContext(), weekPaiment, wyDto);

            Assert.IsNotNull(model);
        }
示例#3
0
 /// <param name="_db"></param>
 /// <param name="weekPaiment"></param>
 /// <returns></returns>
 public static UserWeekPaimentDto MapDto(ApplicationDbContext _db, WeekPaiment weekPaiment)
 {
     return(new UserWeekPaimentDto
     {
         PaiId = weekPaiment.Id,
         Paiment = weekPaiment.Paiment,
         WeekIsPaid = weekPaiment.WeekIsPaid,
         UserName = weekPaiment.WeekOrderMenu.User.LastName + " " + weekPaiment.WeekOrderMenu.User.FirstName,
         WeekPaiments = _db.WeekPaimentByOrderId(weekPaiment.WeekOrderMenu.Id).Result,
         Balance = weekPaiment.WeekOrderMenu.User.Balance,
         Note = weekPaiment.Note,
         PrevWeekBalance = weekPaiment.PreviousWeekBalance
     });
 }
        public async Task <IHttpActionResult> UpdateNote([FromBody] NoteUpdateDto upNoteDto)
        {
            if (upNoteDto == null)
            {
                return(BadRequest());
            }
            ApplicationDbContext db   = _unitOfWork.GetContext();
            WeekPaiment          wpai = db.WeekPaiments.Include("WeekOrderMenu").FirstOrDefault(wp => wp.Id == upNoteDto.Id);

            if (wpai != null)
            {
                wpai.Note            = upNoteDto.Note;
                db.Entry(wpai).State = EntityState.Modified;
                await _unitOfWork.SaveChangesAsync();
            }

            return(Ok(true));
        }
        public async Task <IHttpActionResult> GetUserWeekOrderDto([FromBody] WeekYearDto wyDto)
        {
            string userid = RequestContext.Principal.Identity.GetUserId();

            if (wyDto == null)
            {
                wyDto = YearWeekHelp.GetCurrentWeekYearDto();
            }

            WeekPaiment weekPaiment = _weekPaimentService.GetByUseridWeekYear(userid, wyDto);

            EmployeeWeekOrderDto model = null;

            if (weekPaiment != null)
            {
                model = EmployeeWeekOrderDto.MapDto(_db, weekPaiment, wyDto);
            }


            return(Ok(model));
        }