public ActionResult Edit(EditTemplateViewModel editTemplateViewModel)
        {
            editTemplateViewModel.PageId = "Template";
            if (editTemplateViewModel.fileUpload != null && editTemplateViewModel.fileUpload.ContentLength > 0)
            {
                if (editTemplateViewModel.fileUpload.FileName.Split('.')[1] != "docx")
                {
                    ModelState.AddModelError("error", "فرمت فایل قالب باید ورد باشد.");
                    return(View(editTemplateViewModel));
                }

                //addTemplateViewModel.template.File = new ArchiveFile();
                //Get Content of image
                MemoryStream target = new MemoryStream();
                editTemplateViewModel.fileUpload.InputStream.CopyTo(target);
                editTemplateViewModel.template.File.Content = target.ToArray();
                //addTemplateViewModel.template.File.Name = addTemplateViewModel.fileUpload.FileName;
                editTemplateViewModel.template.File.ContentType = editTemplateViewModel.fileUpload.ContentType;
            }
            else
            {
                ModelState.AddModelError("error", "فایل قالب وارد نشده است.");
                return(View(editTemplateViewModel));
            }

            TemplateManager templateManager = new TemplateManager();

            templateManager.Update(editTemplateViewModel.template);
            templateManager.saveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult Edit(EditTemplateViewModel model)
        {
            var template = db.Templates.FirstOrDefault(x => x.TemplateId == model.editTemplateId);

            template.TemplateName = model.editTemplateName;
            template.VendorName   = model.editTemplateVendorName;
            db.SaveChanges(UserName, IpAddress);

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(Guid id)
        {
            var model = await EditTemplateViewModel.LoadAsync(_ctx, id);

            if (model != null)
            {
                return(View(model));
            }

            return(NotFound());
        }
        public async Task <IActionResult> Edit(Guid id, EditTemplateViewModel model)
        {
            if (ModelState.IsValid)
            {
                await model.SaveChangesAsync(_ctx);

                return(RedirectToAction(nameof(Details), new { id }));
            }

            return(View(model));
        }
        private async void Restore(IDataBase dataBase)
        {
            if (this.isFirst == true)
            {
                return;
            }

            this.isFirst = true;

            var domainContext = dataBase.GetService(typeof(IDomainContext)) as IDomainContext;
            var items         = await domainContext.Dispatcher.InvokeAsync(() =>
            {
                var restoreList = new List <System.Action>();
                var domains     = domainContext.Domains.Where(item => item.DataBaseID == dataBase.ID).ToArray();

                foreach (var item in domains)
                {
                    if (item.Users.Contains(this.authenticator.ID) == false)
                    {
                        continue;
                    }

                    var itemPath = item.DomainInfo.ItemPath;
                    var itemType = item.DomainInfo.ItemType;

                    if (item.Host is ITypeTemplate template)
                    {
                        if (itemType == "NewTypeTemplate")
                        {
                            var category = dataBase.TypeContext[itemPath] as ITypeCategory;
                            var dialog   = new NewTypeViewModel(this.authenticator, category, template);
                            restoreList.Add(new System.Action(() => dialog.ShowDialog()));
                        }
                        else if (itemType == "TypeTemplate")
                        {
                            var type   = dataBase.TypeContext[itemPath] as IType;
                            var dialog = new EditTemplateViewModel(this.authenticator, type, template);
                            restoreList.Add(new System.Action(() => dialog.ShowDialog()));
                        }
                    }
                }
                return(restoreList.ToArray());
            });

            foreach (var item in items)
            {
                if (this.cremaAppHost.IsLoaded == false)
                {
                    return;
                }

                item();
            }
        }
        public ActionResult Clone(EditTemplateViewModel model)
        {
            var existingTemplate = db.Templates.First(x => x.TemplateId == model.editTemplateId);
            var newTemplate      = new Template
            {
                TemplateName     = model.editTemplateName,
                VendorName       = model.editTemplateVendorName,
                Filters          = existingTemplate.Filters,
                OneRosterVersion = existingTemplate.OneRosterVersion
            };

            db.Templates.Add(newTemplate);
            db.SaveChanges(UserName, IpAddress);

            return(RedirectToAction("Index", "Exports", new { templateId = newTemplate.TemplateId }));
        }
Exemple #7
0
        public static async Task <bool> EditTemplateAsync(Authentication authentication, ITypeDescriptor descriptor)
        {
            var comment = await LockAsync(authentication, descriptor, "EditTemplate");

            if (comment == null)
            {
                return(false);
            }

            var dialog = await EditTemplateViewModel.CreateInstanceAsync(authentication, descriptor);

            var dialogResult = await ShowDialogAsync(dialog);

            await UnlockAsync(authentication, descriptor, comment);

            return(dialogResult);
        }
Exemple #8
0
        public async Task <IActionResult> Update([FromRoute] string id, [FromForm] EditTemplateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(nameof(Edit), model));
            }

            var template = await _service.LookupAsync(id);

            if (template == null)
            {
                return(NotFound());
            }

            await _service.UpdateAsync(template.Id, model.CurrentId, model.Name, model.Template);

            return(RedirectToAction(nameof(List)));
        }
        public ActionResult Edit(Guid id)
        {
            EditTemplateViewModel editTemplateViewModel = new EditTemplateViewModel {
                PageId = "Template"
            };
            TemplateManager templateManager = new TemplateManager();

            editTemplateViewModel.template = templateManager.Read(id);

            if (editTemplateViewModel.template != null)
            {
                editTemplateViewModel.PreViewImage =
                    getSampleLetter(new MemoryStream(editTemplateViewModel.template.File.Content));

                return(View(editTemplateViewModel));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        public EditTemplatePage(EditTemplateViewModel viewModel)
        {
            InitializeComponent();

            BindingContext = this.viewModel = viewModel;
        }