Ejemplo n.º 1
0
        public ActionResult <JsonResponse> PostPortraitMethod(Portrait NewPortrait, int admin_id, string admin_token)
        {
            if (authenticator.VerifyAdminForLeaf(admin_id, NewPortrait.site_id, admin_token))
            {
                List <string> errors = authenticator.ValidateIncomingComponent(NewPortrait);
                if (errors.Count == 0)
                {
                    DataPlan data_plan;
                    try{
                        data_plan = _dataLimiter.ValidateComponentAdditionForDataPlan(admin_id, NewPortrait);
                    }catch (System.ArgumentException e) {
                        return(StatusCode(400, e.Message));
                    }

                    NewPortrait.byte_size = NewPortrait.FindCharLength();
                    dbQuery.AddPortrait(NewPortrait);
                    _dataLimiter.UpdateDataPlan(data_plan);

                    JsonResponse r = new JsonSuccess("Portrait posted sucessfully!");
                    return(r);
                }
                else
                {
                    return(StatusCode(400, errors));
                }
            }
            else
            {
                return(StatusCode(400, "Invalid Token. Stranger Danger."));
            }
        }