Exemplo n.º 1
0
        public async Task <ActionResult> SearchEdit_Partial(EditModel model)
        {
            using (SearchDataProvider dataProvider = new SearchDataProvider()) {
                SearchData data = await dataProvider.GetItemWithUrlAsync(model.SearchDataId);

                if (data == null)
                {
                    throw new Error(this.__ResStr("alreadyDeleted", "The search keyword with id {0} has been removed and can no longer be updated.", model.SearchDataId));
                }

                if (!ModelState.IsValid)
                {
                    return(PartialView(model));
                }

                data = model.GetData(data); // merge new data into original
                model.SetData(data);        // and all the data back into model for final display

                switch (await dataProvider.UpdateItemAsync(data))
                {
                default:
                case UpdateStatusEnum.RecordDeleted:
                    throw new Error(this.__ResStr("alreadyDeleted", "The search keyword with id {0} has been removed and can no longer be updated.", model.SearchDataId));

                case UpdateStatusEnum.NewKeyExists:
                    throw new Error(this.__ResStr("alreadyExists", "A search keyword with id {0} already exists.", model.SearchDataId));

                case UpdateStatusEnum.OK:
                    break;
                }
                return(FormProcessed(model, this.__ResStr("okSaved", "Search keyword saved"), OnClose: OnCloseEnum.Return, OnPopupClose: OnPopupCloseEnum.ReloadModule));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> SearchEdit(int searchDataId)
        {
            if (!SearchDataProvider.IsUsable)
            {
                return(View("SearchUnavailable_Edit"));
            }
            using (SearchDataProvider dataProvider = new SearchDataProvider()) {
                EditModel model = new EditModel {
                };
                SearchData data = await dataProvider.GetItemWithUrlAsync(searchDataId);

                if (data == null)
                {
                    throw new Error(this.__ResStr("notFound", "Search keyword with id {0} not found."), searchDataId);
                }
                model.SetData(data);
                return(View(model));
            }
        }