Пример #1
0
 public ActionResult Create(Form newForm)
 {
     _logger.LogDebug("Received Name: " + newForm.Name);
     _logger.LogDebug("Received Desc: " + newForm.Desc);
     try
     {
         // TODO: Add insert logic here
         //return RedirectToAction(nameof(Index));
         newForm.Id           = Guid.NewGuid().ToString();
         newForm.ClientId     = GetUserObjectId();
         newForm.Cors         = "";
         newForm.ApiKey       = Guid.NewGuid().ToString();
         newForm.FormTemplate = new FormTemplate(new MessageFormat());
         _formRepository.InsertOrUpdateForm(GetUserObjectId(), newForm);
         FormApiMap newFormApiMap = new FormApiMap();
         newFormApiMap.ApiKey = newForm.ApiKey;
         //newFormApiMap.ClientId = GetUserObjectId();
         //newFormApiMap.FormId = newForm.Id;
         //newFormApiMap.NumberOfRequests = 0;
         newFormApiMap.EmailInfo = newForm.FormTemplate;
         _apiFormRepository.InsertUpdateFormApiMap(GetUserObjectId(), newFormApiMap);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
        public async Task <ActionResult> Edit(string id, FormTemplate editedFormTemplate)
        {
            try
            {
                //return View();
                Form editedForm = await _formRepository.GetForm(GetUserObjectId(), id);

                editedForm.FormTemplate = editedFormTemplate;
                _formRepository.InsertOrUpdateForm(GetUserObjectId(), editedForm);
                FormApiMap formApiMap = await _apiFormRepository.GetFormApiMap(editedForm.ApiKey);

                formApiMap.EmailInfo = editedFormTemplate;
                _apiFormRepository.InsertUpdateFormApiMap(GetUserObjectId(), formApiMap);
                ViewData["FormId"] = id;
                //return RedirectToAction(nameof(FormController.Index), "Form");
                return(View(editedFormTemplate));
            }
            catch
            {
                return(View());
            }
        }