private Model CreateModelFromCsv(string[] csvHeader, string[] data)
        {
            var result = new Model();

            for (int i = 0; i < csvHeader.Length; i++)
            {
                var pi = result.GetType().GetProperty(csvHeader[i]);

                if (pi != null && pi.CanWrite)
                {
                    var csvVal = data[i];

                    if (csvVal.Equals(CsvNull))
                    {
                        pi.SetValue(result, null);
                    }
                    else if (pi.PropertyType.IsEnum)
                    {
                        pi.SetValue(result, Enum.Parse(pi.PropertyType, csvVal));
                    }
                    else
                    {
                        pi.SetValue(result, Convert.ChangeType(csvVal, pi.PropertyType));
                    }
                }
            }
            return(result);
        }
        private Model ConvertTo(Contract entity)
        {
            var result = new Model();

            result.CopyProperties(entity);
            return(result);
        }
        public async Task <IActionResult> CreateAsync(Model model)
        {
            using var ctrl = Factory.Create <Contract>(SessionWrapper.LoginSession.SessionToken);

            try
            {
                await ctrl.InsertAsync(model);

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception ex)
            {
                model.ActionError = ex.Message;
            }
            return(View(model));
        }