Пример #1
0
        public ActionResult AddEditableOrganization(string Selecteds)
        {
            RequestResult result = new RequestResult();

            try
            {
                List <Guid> selectedList = JsonConvert.DeserializeObject <List <Guid> >(Selecteds);

                if ((Define.EnumFormAction)Session["OrganizationFormAction"] == Define.EnumFormAction.Create)
                {
                    var model = Session["OrganizationCreateFormModel"] as CreateFormModel;

                    result = OrganizationDataAccessor.AddEditableOrganization(model.EditableOrganizations, selectedList, Session["Account"] as Account);

                    if (result.IsSuccess)
                    {
                        model.EditableOrganizations = result.Data as List <EditableOrganizationModel>;

                        Session["OrganizationCreateFormModel"] = model;
                    }
                }
                else if ((Define.EnumFormAction)Session["OrganizationFormAction"] == Define.EnumFormAction.Edit)
                {
                    var model = Session["OrganizationEditFormModel"] as EditFormModel;

                    result = OrganizationDataAccessor.AddEditableOrganization(model.EditableOrganizations, selectedList, Session["Account"] as Account);

                    if (result.IsSuccess)
                    {
                        model.EditableOrganizations = result.Data as List <EditableOrganizationModel>;

                        Session["OrganizationEditFormModel"] = model;
                    }
                }
                else
                {
                    result.ReturnFailedMessage(Resources.Resource.UnKnownOperation);
                }
            }
            catch (Exception ex)
            {
                Error err = new Error(MethodBase.GetCurrentMethod(), ex);

                Logger.Log(err);

                result.ReturnError(err);
            }

            return(Content(JsonConvert.SerializeObject(result)));
        }