コード例 #1
0
        internal Result AddBeverage(AddNewBeverage request)
        {
            try
            {
                context.Beverages.InsertOnSubmit(new Beverage()
                {
                    AlcoholPercentage = request.alcaholPercent,
                    DateCreated       = DateTime.Now,
                    ImageUrlSm        = request.imageUrl,
                    Name       = request.name,
                    MajorGroup = request.majorGroupId,
                    Type       = request.type,
                    IpAddress  = request.ipAddress,
                    Accepted   = false
                }
                                                 );

                context.SubmitChanges();
                return(new Result(ResultStatus.SUCCESS, "Beverage created"));
            }
            catch (Exception ex)
            {
                return(new Result(ResultStatus.ERROR, ex.Message));
            }
        }
コード例 #2
0
        public HttpResponseMessage AddBeverage(AddNewBeverage request)
        {
            request.ipAddress = GetUser_IP();
            Result result = dal.AddBeverage(request);

            return(ApiTools.CreateResponse(result, Request));
        }