コード例 #1
0
        public Newtonsoft.Json.Linq.JObject UpdateFormulariumName(int id, string newName)
        {
            bool isSuccess = false;
            //int id = request.Value<int>("id");
            //string newName = request.Value<string>("newName");

            Formularium formularium = null;

            if (Formularium.Exists(id) && !string.IsNullOrEmpty(newName))
            {
                formularium = Formularium.GetFormularium(id);
            }

            if (formularium != null)
            {
                formularium.FormulariumName = newName;
                if (formularium.IsSavable)
                {
                    formularium = formularium.Save();
                    isSuccess   = true;
                }
            }

            Newtonsoft.Json.JsonSerializer ser  = new JsonSerializer();
            Newtonsoft.Json.Linq.JObject   json = Newtonsoft.Json.Linq.JObject.FromObject(new { success = isSuccess }, ser);

            return(json);
        }
コード例 #2
0
        public Newtonsoft.Json.Linq.JObject GetFormulariumById(Newtonsoft.Json.Linq.JObject request)
        {
            Formularium formularium = Formularium.GetFormularium(request.Value <int>("id"));

            Newtonsoft.Json.JsonSerializer ser  = new JsonSerializer();
            Newtonsoft.Json.Linq.JObject   json = Newtonsoft.Json.Linq.JObject.FromObject(formularium, ser);

            return(json);
        }
コード例 #3
0
        public ActionResult GetFormularium(int id)
        {
            Formularium formularium = null;

            if (Formularium.Exists(id))
            {
                formularium = Formularium.GetFormularium(id);
            }

            return(this.Direct(formularium));
        }
コード例 #4
0
        public ActionResult SaveFormularium(FormulariumData formulariumData)
        {
            Formularium formulariumToSave = null;

            // Look whether Formularium exists. Then get that Formularium, else create a new one
            if (Formularium.Exists(formulariumData.Id))
            {
                formulariumToSave = Formularium.GetFormularium(formulariumData.Id);
            }
            else
            {
                formulariumToSave = Formularium.NewFormularium(formulariumData.FormulariumName, formulariumData.MainAuthorUserName);
            }

            bool canBeMapped = true;

            if (!formulariumToSave.IsNew)
            {
                canBeMapped = CheckVersion(formulariumToSave.TimeStamp, formulariumData.TimeStamp);
            }

            if (canBeMapped)
            {
                // Map the properties of formulariumData and formulariumToSave, except the MainGroups collection
                string[] exlude = { "MainGroups",   "Texts",        "DoseTexts",
                                    "ProductTexts", "GenericTexts",
                                    "Pharmacy",     "PharmacyId" };

                Csla.Data.DataMapper.Map(formulariumData, formulariumToSave, exlude);
            }

            // Return the result
            return(this.Direct(
                       new
            {
                success = formulariumToSave.IsSavable,
                data = formulariumToSave.IsSavable ? formulariumToSave.Save(): formulariumToSave,
                msg = formulariumToSave.BrokenRulesCollection.ToString()
            }));
        }