示例#1
0
        public async Task <IActionResult> CreateAsync(
            [FromBody] Wppod.Models.User user)
        {
            Cloud.Result <Wppod.Models.User> result =
                new Cloud.Result <Wppod.Models.User>();

            try
            {
                if (!ModelState.IsValid)
                {
                    result.SetFail("Invalid model state");
                }
                else
                {
                    string status = string.Format("User Create request, received by Nest-{0}.{1} at {2}",
                                                  _runtime.NestTag, _runtime.CushionIndex, DateTime.Now.ToString("t"));
                    _logger.LogInformation(status);

                    _cafeContext.Users.Add(user);
                    await _cafeContext.SaveChangesAsync();

                    result.SetSuccess("user", user);
                }
            }
            catch (System.Exception e)
            {
                result.SetFail(e, "CreateAsync");
            }

            return(Ok(result));
        }
示例#2
0
        public IActionResult Get(string email)
        {
            Cloud.Result <Wppod.Models.User> result =
                new Cloud.Result <Wppod.Models.User>();

            try
            {
                Wppod.Models.User user = _cafeContext.Users.FirstOrDefault(
                    searchUser => searchUser.Email == email);

                if (user == null)
                {
                    result.SetFail("User not found");
                }
                else
                {
                    result.SetSuccess("user", user);
                }
            }
            catch (System.Exception e)
            {
                result.SetFail(e, "Query");
            }

            return(Ok(result));
        }
示例#3
0
        public IActionResult Get()
        {
            Cloud.Result <Wppod.Models.User> result =
                new Cloud.Result <Wppod.Models.User>();

            result.SetSuccess("users", _cafeContext.Users.ToList());

            return(Ok(result));
        }
示例#4
0
        public IActionResult Get()
        {
            Cloud.Result <Wppod.Models.Stock> result =
                new Cloud.Result <Wppod.Models.Stock>();

            result.SetSuccess("stocks", _cafeContext.Stocks.ToList());

            return(Ok(result));
        }
示例#5
0
        public IActionResult Get([FromQuery] string date)
        {
            Cloud.Result <Wppod.Models.Order> result =
                new Cloud.Result <Wppod.Models.Order>();

            try
            {
                System.Linq.IQueryable <Wppod.Models.Order> items = null;

                if (date != null && date.Length > 0)
                {
                    DateTime checkTime = DateTime.Parse(date);
                    items = _cafeContext.Orders
                            .Where(searchOrder => searchOrder.VisitDate.Date == checkTime.Date);
                }
                else
                {
                    items = _cafeContext.Orders;
                }

                if (items == null)
                {
                    result.SetFail("Orders not found");
                }
                else
                {
                    result.SetSuccess("orders", items.ToList());
                }
            }
            catch (System.Exception e)
            {
                result.SetFail(e, "GetAsync");
            }

            return(Ok(result));
        }