public static MessageModel GetMessage(this HtmlHelper html, string prefix, FormModel form)
        {
            MessageModel msg = new MessageModel();

            ViewDataDictionary viewData = html.ViewDataContainer.ViewData;

            if (!viewData.ModelState.IsValid)
            {
                msg.Errors = viewData.ModelState.GetErrors(prefix);
            }

            if (null != form)
            {
                if (null != form.Notice && form.Notice.Count() != 0)
                {
                    // List<string> notice = new List<string>();

                    msg.Notice = form.Notice;
                }

                //todo:success

                if (null != viewData["Message"])
                {
                    msg.Success = new string[] { (string)viewData["Message"] };
                }
            }

            return msg;
        }
        public virtual void HandleSubmission(FormModel model, IPublishedContent content)
        {
            var cookieValue = (Request.Cookies.AllKeys.Contains(FormSubmittedCookieKey) ? Request.Cookies[FormSubmittedCookieKey].Value : null) ?? string.Empty;
            var containsCurrentContent = cookieValue.Contains(FormSubmittedCookieValue(content));

            if(model.DisallowMultipleSubmissionsPerUser == false)
            {
                if(containsCurrentContent)
                {
                    // "only one submission per user" must've been enabled for this form at some point - explicitly remove the content ID from the cookie
                    cookieValue = cookieValue.Replace(FormSubmittedCookieValue(content), ",");
                    if(cookieValue == ",")
                    {
                        // this was the last content ID - remove the cookie
                        Response.Cookies.Add(new HttpCookie(FormSubmittedCookieKey, cookieValue) { Expires = DateTime.Today.AddDays(-1) });
                    }
                    else
                    {
                        // update the cookie value
                        Response.Cookies.Add(new HttpCookie(FormSubmittedCookieKey, cookieValue) { Expires = DateTime.Today.AddDays(30) });
                    }
                }

                return;
            }

            // add the content ID to the cookie value if it's not there already
            if(containsCurrentContent == false)
            {
                cookieValue = string.Format("{0}{1}", cookieValue.TrimEnd(','), FormSubmittedCookieValue(content));
            }
            Response.Cookies.Add(new HttpCookie(FormSubmittedCookieKey, cookieValue) { Expires = DateTime.Today.AddDays(30) });
        }
 public virtual bool CanSubmit(FormModel model, IPublishedContent content)
 {
     if(model.DisallowMultipleSubmissionsPerUser == false)
     {
         return true;
     }
     var cookie = Request.Cookies[FormSubmittedCookieKey];
     return cookie == null || cookie.Value.Contains(FormSubmittedCookieValue(content)) == false;
 }
        public void CreateVehicle()
        {
            var vehicle = new FormModel
            {
                VehicleNumbers   = "RP-1223",
                YearOfProduction = 2010
            };

            var result = vehicleService.Create(vehicle);

            Assert.IsNotNull(result);
        }
Example #5
0
        public void UpdateBrand()
        {
            var brand = new FormModel
            {
                Id   = 2,
                Name = "Test10",
            };

            var result = brandService.Update(brand);

            Assert.IsNotNull(result);
        }
Example #6
0
        public void UpdateCountry()
        {
            var country = new FormModel
            {
                Id   = 1,
                Name = "Test10",
            };

            var result = countryService.Update(country);

            Assert.IsNotNull(result);
        }
        public void UpdateModelVehicle()
        {
            var modelVehicle = new FormModel
            {
                Id   = 1,
                Name = "Test10",
            };

            var result = modelVehicleService.Update(modelVehicle);

            Assert.IsNotNull(result);
        }
Example #8
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Phone,Email,Gender,Password,Country,Terms")] FormModel formModel)
        {
            if (ModelState.IsValid)
            {
                db.formModels.Add(formModel);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(formModel));
        }
        public void UpdateProvincy()
        {
            var provincy = new FormModel
            {
                Id   = 1,
                Name = "Test10",
            };

            var result = provincyService.Update(provincy);

            Assert.IsNotNull(result);
        }
Example #10
0
        public ActionResult Forms(int formId)
        {
            if (Session["UserName"] == null)
            {
                return(RedirectToAction("Index", "User"));
            }

            FormModel formModel = formService.GetForm(formId);


            return(View(formModel));
        }
        public void UpdateOperatorContainer()
        {
            var operatorContainer = new FormModel
            {
                Id   = 1,
                Name = "Test10",
            };

            var result = operatorContainerService.Update(operatorContainer);

            Assert.IsNotNull(result);
        }
        public bool GetFormsFillingValue(FormModel form, int userID)
        {
            using var command = _connection.CreateCommand();

            command.CommandText = $"SELECT form_is_filled FROM users_forms_connect WHERE form_id = {form.FormID} AND user_id = {userID}";


            using var reader = command.ExecuteReader();
            reader.Read();

            return(Convert.ToBoolean(reader["form_is_filled"]));
        }
Example #13
0
        public static FormModel SetPropertyValuesToPropertyNames(this FormModel formModel)
        {
            foreach (var prop in formModel.GetType().GetProperties())
            {
                if (prop.PropertyType == typeof(string))
                {
                    prop.SetValue(formModel, prop.Name, null);
                }
            }

            return(formModel);
        }
        public void SetSessionVariables(string UserName)
        {
            //UserModel user =_UserService.GetUserByName(UserName);

            var user = _UserService.GetUserByName(UserName);

            if (user != null) //By Email Id
            {
                var Role   = _UserRoleService.Role().Where(x => x.UserId == user.UserId).FirstOrDefault();
                int RoleId = Role.RoleId; //Get RoleId

                var RoleDetails = _RoleDetailService.GetRoleDetails(RoleId);
                var models      = new List <RoleDetailModel>();

                Mapper.CreateMap <CommunicationApp.Entity.RoleDetail, CommunicationApp.Models.RoleDetailModel>();
                foreach (var roledetail in RoleDetails)
                {
                    var _roleDetail = Mapper.Map <CommunicationApp.Entity.RoleDetail, CommunicationApp.Models.RoleDetailModel>(roledetail);

                    FormModel formModal = new FormModel();
                    formModal.FormId         = _roleDetail.FormId;
                    formModal.FormName       = _FormService.GetForm(roledetail.FormId).FormName;
                    formModal.ControllerName = _FormService.GetForm(roledetail.FormId).ControllerName;
                    _roleDetail.form         = formModal;
                    //_roleDetail.FormName = _FormService.GetForm(roledetail.FormId).ControllerName;
                    //_roleDetail.ControllerName =_FormService.GetForm(roledetail.FormId).ControllerName;
                    models.Add(_roleDetail);
                }
                var lstRoleDetail = models; //Get Permission


                Session["RoleType"]       = _RoleService.GetRoles().Where(x => x.RoleId == RoleId).Select(x => x.RoleType).FirstOrDefault();
                Session["UserPermission"] = lstRoleDetail;

                Session["UserId"] = user.UserId; //Set User Id
                var Customer = _CustomerService.GetCustomers().Where(c => c.UserId == user.UserId).FirstOrDefault();
                if (Customer != null)
                {
                    Session["CustomerID"]  = Customer.CustomerId;
                    Session["Designation"] = Customer.Designation;
                    Session["AdminPhoto"]  = Customer.PhotoPath;
                }

                Session["CompanyID"] = user.CompanyID;               //Set Company Id

                Session["CompanyName"] = user.Companies.CompanyName; //Set Company Name
                Session["LogoPath"]    = user.Companies.LogoPath;

                Session["UserName"]     = user.UserName;
                Session["FullUserName"] = (user.FirstName + " " + user.LastName).Trim();
                //Set Logo
            }
        }
Example #15
0
        public async Task <LightMessage> SaveNewImgMessageAsync(FormModel form)
        {
            var    imgName = $"{Guid.NewGuid()} { form.File.FileName}";
            string path    = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Images", imgName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                form.File.CopyTo(stream);
            }

            return(await CreateMessageForUserAsync(form.Receiver, form.Text, form.Sender, $"Images/{imgName}"));
        }
        public void CreateOperatorVehicle()
        {
            var operatorVehicle = new FormModel
            {
                OperatorId = 3,
                VehicleId  = 5
            };

            var result = operatorVehicleService.Create(operatorVehicle);

            Assert.IsNotNull(result);
        }
        private FormModel GetFormRequest()
        {
            FormModel oReturn = new FormModel();

            if (!string.IsNullOrEmpty(Request["UpsertAction"]) && Request["UpsertAction"].Trim() == "true")
            {
                oReturn.FormPublicId = Request["FormPublicId"];
                oReturn.Name         = Request["Name"];
            }

            return(oReturn);
        }
 public void ModifyForm(FormModel form)
 {
     try
     {
         _context.complaintFormModels.Update(form);
         _context.SaveChanges();
     }
     catch (Exception ex)
     {
         _logger.LogError("Can't update form information", ex);
     }
 }
        public ActionResult CustomForm([FromBody] FormModel newForm)
        {
            returnString = string.Empty;

            var recognizerClient = AuthenticateClient();

            var analyzeForm = AnalyzeCustomForm(recognizerClient, newForm.modelID, newForm.formURL);

            Task.WaitAll(analyzeForm);

            return(Ok(returnString));
        }
Example #20
0
        private void OnPriceFiltersLoaded(CommandBase command)
        {
            command.CommandFinished -= OnPriceFiltersLoaded;
            var loadPriceRangeCommand = (ILoadPriceRangeCommand)command;
            var commandResult         = loadPriceRangeCommand.PriceRangeResult;

            FormModel.ShowingItemsInfo.ChangePriceFilter(commandResult.MinPriceRange, commandResult.MaxPriceRange);

            FormModel.MinPriceRange = commandResult.MinPriceRange;
            FormModel.MaxPriceRange = commandResult.MaxPriceRange;
            FormModel.SetChanges();
        }
Example #21
0
 public IActionResult Insert(FormModel formModel)
 {
     if (ModelState.IsValid)
     {
         return(View(formModel));
     }
     else
     {
         ModelState.AddModelError("Error", "Invalid data");
         return(View(formModel));
     }
 }
Example #22
0
        public JsonResult Post([FromBody] FormModel request)
        {
            List <Asset> response = null;

            if (ModelState.IsValid && request != null)
            {
                Data.PopulateData(request);
                response = Data.Assets;
            }

            return(Json(response));
        }
Example #23
0
        public async Task OnGetAsync(string Id)
        {
            var room = await this.dbContext.Rooms.FindAsync(Id);

            if (room != null)
            {
                this.Input              = new FormModel();
                this.Input.FloorNumber  = room.FloorNumber;
                this.Input.RoomNumber   = room.RoomNumber;
                this.Input.RoomCategory = Guid.Parse(room.RoomCategoryId);
            }
        }
Example #24
0
        public static FormModel GetNewGroupFormFor(string _option, string _channel, string _id, string _name, string _order, string block_channel)
        {
            FormModel form = new FormModel();

            form.controller = new ConfigController().CONTROLLER_NAME;
            form.action     = "SaveNewGroup";
            form.form_id    = _option;
            string table = "";

            switch (_option)
            {
            default:
                table = StrawmanDBLibray.Classes.StrawmanDataTables.MARKET_GROUPS;
                break;
            }
            int channel = 0;

            if (!int.TryParse(_channel, out channel))
            {
                channel = 1;
            }
            List <KeyValuePair <string, string> > cgatributes = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("data-type", Classes.Default.Attributes.CHANNEL_ID),
                new KeyValuePair <string, string>("value", channel.ToString()),
                new KeyValuePair <string, string>("disabled", bool.Parse(block_channel ?? "false")?"disabled":null)
            };
            List <KeyValuePair <string, string> > ngatributes = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("data-type", Classes.Default.Attributes.GROUP_NAME_ID),
                new KeyValuePair <string, string>("value", _name)
            };
            List <KeyValuePair <string, string> > igatributes = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("data-type", Classes.Default.Attributes.GROUP_ID),
                new KeyValuePair <string, string>("value", _id)
            };
            List <KeyValuePair <string, string> > ogatributes = new List <KeyValuePair <string, string> >()
            {
                new KeyValuePair <string, string>("data-type", Classes.Default.Attributes.ORDER_ID),
                new KeyValuePair <string, string>("value", _order)
            };

            //Select for Channel
            //Input for Name
            form.objects.Add(GetFormElement(FormUtilModel.InputTypes.SELECT, 1, 1, Helpers.MessageByLanguage.Channel, true, Classes.Default.Attributes.CHANNEL_ID, new ConfigController().GetChannelList(channel), cgatributes));
            form.objects.Add(GetFormElement(FormUtilModel.InputTypes.TEXT, 1, 2, Helpers.MessageByLanguage.Name, true, Classes.Default.Attributes.GROUP_NAME_ID, _name, ngatributes));
            form.objects.Add(GetFormElement(FormUtilModel.InputTypes.TEXT, 2, 2, Helpers.MessageByLanguage.Order, true, Classes.Default.Attributes.ORDER_ID, _order, ogatributes));
            form.objects.Add(GetFormElement(FormUtilModel.InputTypes.HIDDEN, 0, 0, null, false, Classes.Default.Attributes.GROUP_ID, _id, igatributes));
            form.objects.Add(GetFormElement(FormUtilModel.InputTypes.HIDDEN, 0, 0, null, false, Classes.Default.Attributes.INPUT_TABLE_ID, table, null));
            return(form);
        }
Example #25
0
        public string SendMail(long siteId, long menuId, FormMailModel mail, string[] fileList, string recipientIds, string recipientEmails, bool isTest, bool?isEvent = false)
        {
            if (mail == null || string.IsNullOrWhiteSpace(mail.MailBody))
            {
                return("Mail 為 NULL");
            }

            if (isTest && string.IsNullOrWhiteSpace(recipientEmails))
            {
                return("測試郵件缺少收信人");
            }

            if (!isTest && string.IsNullOrWhiteSpace(recipientIds))
            {
                return("未選擇郵件發送用戶");
            }

            SitesModels site = SitesDAO.GetInfo(siteId);

            System.Collections.ArrayList emailFiles = new System.Collections.ArrayList();
            List <ResourceFilesModels>   files      = new List <ResourceFilesModels>();

            if (fileList?.Length > 0)
            {
                string uploadPath = Golbal.UpdFileInfo.GetUPathByMenuID(siteId, menuId).TrimEnd('\\') + "\\";
                foreach (string item in fileList)
                {
                    ResourceFilesModels file = JsonConvert.DeserializeObject <ResourceFilesModels>(item);
                    files.Add(file);
                    emailFiles.Add(uploadPath + file.FileInfo);
                }
            }
            mail.Files = JsonConvert.SerializeObject(files);

            FormModel form        = FormDAO.GetItem(mail.FormID);
            string    mailSubject = mail.MailSubject.Replace("[WebsiteName]", site.Title).Replace("[SendDate]", DateTime.Now.ToString(WebInfo.DateFmt));
            string    mailBody    = mail.MailBody.Replace("[WebsiteName]", site.Title).Replace("[SendDate]", DateTime.Now.ToString(WebInfo.DateFmt));

            mailSubject = mailSubject.Replace("[FormName]", form.Title);
            mailBody    = mailBody.Replace("[FormName]", form.Title);

            if (isTest)
            {
                SendMailTest(siteId, mail, mailSubject, mailBody, emailFiles, recipientEmails, isEvent);
                return("測試郵件發送成功");
            }

            mail.ID = WorkLib.GetItem.NewSN();
            FormMailDAO.SetItem(mail);
            MailSend(siteId, mail, mailSubject, mailBody, emailFiles, recipientIds);
            return("郵件發送成功");
        }
        public ActionResult Fields(int formId = 0, int userid = 0)
        {
            var fields = db.FormFields.ToList();

            ViewBag.FormField = db.FormFields.Select(x => new FormFieldModel
            {
                FieldName  = x.FieldName,
                FieldType  = x.FieldType,
                Id         = x.Id,
                IsRequired = x.IsRequired,
                SortIndex  = x.SortIndex,
                Icons      = x.Icons,
                Class      = x.Class
            }).ToList();
            var form  = db.Forms.ToList();
            var model = new FormModel();

            var usertable = db.Users.Where(x => x.UserId == userid).FirstOrDefault();

            if (usertable != null)
            {
                model.UserId = usertable.UserId;
            }


            if (formId > 0)
            {
                var formTable = db.Forms.Where(x => x.FormId == formId).FirstOrDefault();
                if (formTable != null)
                {
                    foreach (var item in formTable.FormDetails)
                    {
                        FormFieldModel ffModel = new FormFieldModel
                        {
                            FormDetailId = item.FormDetailId,
                            FieldType    = item.FieldType,
                            Id           = (int)item.Id,
                            FieldName    = item.FieldName,
                            IsRequired   = item.Isrequired,
                            Icons        = item.Icons,
                            SortIndex    = item.Sortindex,
                            Class        = item.Class
                        };
                        model.FormName        = formTable.FormName;
                        model.FormDescription = formTable.FormDescription;
                        model.UserId          = formTable.UserId;
                        model.formField.Add(ffModel);
                    }
                }
            }
            return(View(model));
        }
        public void OnGet(string customer_id)
        {
            this.Input             = new FormModel();
            this.Input.CheckInTime = DateTime.Now;
            this.Input.Nights      = 1;
            this.Rooms             = new SelectList(this.dbContext.Rooms.Where <Room>(room => room.Status == RoomStatues.EMPTY).ToList <Room>(), "Id", "PreferedName");
            this.CalculateCheckoutTime();

            if (customer_id != null)
            {
                this.Input.Customer = this.dbContext.Customers.Find(customer_id);
            }
        }
Example #28
0
        private void OnNavigationClicked(NavigationType navigationType)
        {
            var grid           = _container.GetItemsGrid();
            var currentItemPos = DetectCurrentItemPos(grid);
            var targetItem     = NavigationUtil.GetTarget(grid,
                                                          currentItemPos, navigationType);

            if (targetItem != null && !targetItem.IsBlockForInput)
            {
                FormModel.SelectedItem = targetItem.Model;
                FormModel.SetChanges();
            }
        }
        public void UpdateOperatorVehicle()
        {
            var operatorVehicle = new FormModel
            {
                Id         = 1,
                OperatorId = 3,
                VehicleId  = 3
            };

            var result = operatorVehicleService.Update(operatorVehicle);

            Assert.IsNotNull(result);
        }
        public void Setup()
        {
            Initialize();
            Driver.Navigate().GoToUrl("http://automationpractice.com/index.php?controller=authentication&back=my-account");
            _registrationFormPage = new RegistrationFormPage(Driver);
            _user = FormFactory.Create();

            var fixture = new Fixture();
            var mail    = fixture.Create <string>() + "@gmail.com";

            _registrationFormPage.EmailAddressField.SendKeys(mail);
            _registrationFormPage.CreateAccountButton.Click();
        }
Example #31
0
        public void SetUp()
        {
            Initialize();
            Driver.Navigate().GoToUrl("http://automationpractice.com/index.php");

            home        = new HomePage(Driver);
            accountPage = new AccountCreation(Driver);

            user = FormFactory.Create();
            createAcccountEmail = new CreateAcccountEmailPage(Driver);

            NavigateToForm();
        }
Example #32
0
        public void FillFormWithoutState(FormModel user)
        {
            FirstName.SendKeys(user.FirstName);
            LastName.SendKeys(user.LastName);
            Password.SendKeys(user.Password);
            Address.SendKeys(user.Address);
            City.SendKeys(user.City);
            PostCode.SendKeys(user.PostCode);
            PhoneNumber.SendKeys(user.PhoneNumber);

            Driver.ScrollTo(RegisterButton);
            RegisterButton.Click();
        }
Example #33
0
        private void OnMarketAccessTokenCallback(TokenRequest.Response data, TokenRequest.RequestParams request)
        {
            View.SetWaitState(false);
            View.ClearFields();

            Controller.Login(FormModel.UserLogin, data.token, data.refreshToken);

            FormModel.Clear();
            MarketView.SetActiveTabsPanel(true);
            MarketView.Header.SetActiveLoggedHeaderPanel(true);

            ApplyState <GameInventoryState>();
        }
 public string post_form(FormModel model)
 {
     return "Success";
 }
 public FormModel get_form(FormModel model)
 {
     return model;
 }