Ejemplo n.º 1
0
        public async Task <bool> SaveInDatabase(vm.AdministratorForm info)
        {
            if (!ModelState.IsValid(info))
            {
                Notify(ModelState.GetErrors().ToLinesString(), "error");
                return(false);
            }

            var item = info.Item.Clone();

            await info.CopyDataTo(item); // Read the ViewModel data into the domain object.

            using (var scope = Database.CreateTransactionScope())
            {
                try
                {
                    info.Item = await Database.Save(item);

                    scope.Complete();
                    return(true);
                }
                catch (Olive.Entities.ValidationException ex)
                {
                    Notify(ex.ToFullMessage(), "error");
                }

                return(false);
            }
        }
Ejemplo n.º 2
0
        public async Task OnBound(vm.AdministratorForm info)
        {
            info.Item = info.Item ?? new Administrator();

            if (Request.IsGet())
            {
                await info.Item.CopyDataTo(info);
            }

            info.IsDeactivated_Options.Clear();
            info.IsDeactivated_Options.Add("Yes", true);
            info.IsDeactivated_Options.Add("No", false);
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> Save(vm.AdministratorForm info)
        {
            try
            {
                if (!await SaveInDatabase(info))
                {
                    return(JsonActions(info));
                }
            }
            catch (Olive.Entities.ValidationException ex)
            {
                return(Notify(ex.Message, "error"));
            }

            Notify("Saved successfully.", obstruct: false);

            Do(WindowAction.CloseModalRefreshParent);

            return(JsonActions(info));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> Index(vm.AdministratorForm info)
        {
            ModelState.Clear(); // Remove initial validation messages

            return(View(info));
        }