Esempio n. 1
0
        public async Task <IActionResult> AddTreatment(int foodId, [FromBody] string treatmentId)
        {
            try
            {
                var providerId      = int.Parse(User.Claims.First(c => c.Type == "premisesID").Value);
                var userId          = int.Parse(User.Claims.First(c => c.Type == "userID").Value);
                var transactionHash = await _foodDataBL.AddTreatment(foodId, int.Parse(treatmentId), providerId, userId);

                await _foodBL.AddDetail(foodId, EFoodDetailType.TREATMENT, transactionHash, userId);

                Entities.ProviderFood food = await _foodBL.getFoodById(foodId, providerId);

                await _foodBL.UpdateFoodTreatment(food, foodId, int.Parse(treatmentId), providerId);

                return(Ok(new { message = MessageConstant.INSERT_SUCCESS }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = MessageConstant.UNHANDLE_ERROR, error = ex.StackTrace }));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> CreateProviderFood([FromBody] Models.CreateProviderFoodRequest foodRequest)
        {
            try
            {
                Entities.ProviderFood food = _mapper.Map <Entities.ProviderFood>(foodRequest);
                food.PremisesId = int.Parse(User.Claims.First(c => c.Type == "premisesID").Value);
                var createById = int.Parse(User.Claims.First(c => c.Type == "userID").Value);

                var transactionHash = await _foodDataBL.AddProvider(food.FoodId, int.Parse(User.Claims.First(c => c.Type == "premisesID").Value), createById);

                await _foodBL.AddDetail(food.FoodId, EFoodDetailType.PROVIDER, transactionHash, createById);

                await _foodBL.createProviderFood(food);

                return(Ok(new { message = MessageConstant.INSERT_SUCCESS }));
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = MessageConstant.UNHANDLE_ERROR, error = ex.StackTrace }));
            }
        }