Esempio n. 1
0
        public JsonResult SendProduct(int destinationID, int productID, int quality, int amount)
        {
            try
            {
                var source      = SessionHelper.CurrentEntity;
                var destination = entityRepository.GetById(destinationID);
                var productType = (ProductTypeEnum)productID;

                MethodResult result = giftService.CanSendProductGift(source, destination, productType, quality, amount);
                if (result.IsError)
                {
                    return(JsonError(result));
                }

                giftService.SendProductGift(source, destination, productType, quality, amount);
                return(JsonSuccess($"{productType.ToHumanReadable().FirstUpper()} successfully sent!"));
            }
            catch (Exception e)
            {
                return(JsonError("Undefined error"));
            }
        }