コード例 #1
0
        public IActionResult Create([FromBody] CreateOrderType orderTypeDto)
        {
            var similerOrderType = this._context.OrderTypes.Where(c => c.Name.Equals(orderTypeDto.Name)).FirstOrDefault();

            if (similerOrderType != null)
            {
                return(Conflict());
            }

            OrderType orderType = new OrderType()
            {
                Name = orderTypeDto.Name
            };

            _context.Add(orderType);
            _context.SaveChanges();
            OrderTypeDto response = new OrderTypeDto()
            {
                Id        = orderType.Id,
                Name      = orderType.Name,
                CanDelete = true
            };

            return(Ok(response));
        }
コード例 #2
0
        public virtual PayloadResponseDto <IEnumerable <D> > GetOwnerOrderByAll([FromQuery] IEnumerable <string> fields, OrderTypeDto orderTypeDto)
        {
            OrderType orderType = (OrderType)orderTypeDto;

            return(new PayloadResponseDto <IEnumerable <D> >
            {
                Payload = this.Mapper.Map <IEnumerable <E>, IEnumerable <D> >(this.Repository.FindAllByCreatedBy(this.GetUserId(), fields, orderType))
            });
        }
コード例 #3
0
        public virtual PayloadResponseDto <PagingDto <D> > GetOwnerPagingOrderAll([FromQuery] IEnumerable <string> fields, OrderTypeDto orderTypeDto, int pageIndex = 1, int pageRange = 5)
        {
            OrderType orderType = (OrderType)orderTypeDto;

            return(new PayloadResponseDto <PagingDto <D> >
            {
                Payload = new PagingDto <D>
                {
                    Items = this.Mapper.Map <IEnumerable <E>, IEnumerable <D> >(this.Repository.FindAllByCreatedBy(this.GetUserId(), pageIndex, pageRange, fields, orderType)),
                    PagingCount = (int)Math.Ceiling((double)this.Repository.Count() / pageRange)
                }
            });
        }