Example #1
0
        public IActionResult Create(Microsoft.AspNetCore.Http.IFormCollection collection)
        {
            try
            {
                ViewData["source"]    = collection["source"];
                ViewData["sensor"]    = collection["sensor"];
                ViewData["parameter"] = collection["parameter"];
                ViewData["value"]     = collection["value"];

                string query = "INSERT INTO indicators (`code`, `unit`, `type`, `value`) VALUES (@Code, @Unit, @Type, @Value)";

                SQLiteCommand command = new SQLiteCommand(query, databaseObject.conn);
                databaseObject.OpenConnection();


                command.Parameters.AddWithValue("@Code", collection["source"]);
                command.Parameters.AddWithValue("@Unit", collection["sensor"]);
                command.Parameters.AddWithValue("@Type", collection["parameter"]);
                command.Parameters.AddWithValue("@Value", collection["value"]);
                var result = command.ExecuteNonQuery();

                databaseObject.CloseConnection();


                Console.WriteLine(result);

                return(View("Create"));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        public async Task <IActionResult> SendForm()
        {
            try
            {
                List <string[]> ListSelected = new List <string[]>();
                Microsoft.AspNetCore.Http.IFormCollection formCollection = HttpContext.Request.Form;
                foreach (string FormPara in formCollection.Keys)
                {
                    if (FormPara.StartsWith("chkS"))
                    {
                        ListSelected.Add(FormPara.Replace("chkS", "").Split('|'));
                    }
                }
                if (ListSelected.Count > 0)
                {
                    IEnumerable <string> ListDispatch = ListSelected.Select(O1 => O1.Fod()).Distinct();
                    string Idusr = HttpContext.Session.GetObjSession <string>("Session.CodUsr");
                    string s1    = await ApiClientFactory.Instance.SendForm856(ListDispatch, Idusr);

                    return(Json(new { data = s1 }));
                }
            }
            catch (Exception e3)
            {
                return(Json(new { data = e3.ToString() }));
            }
            return(Json(new { data = "" }));
        }
Example #3
0
        private async Task <UserCustomerModel> InsertIdentity(Microsoft.AspNetCore.Http.IFormCollection collection,
                                                              UsuarioSistema users)
        {
            string caminhoDestinoArquivoOriginal = await Uploadfile(collection, users.Nome);

            if (!string.IsNullOrEmpty(caminhoDestinoArquivoOriginal))
            {
                users.PathPhoto = caminhoDestinoArquivoOriginal;
            }

            //add user no aspnetuser
            var user = new UserCustomerModel
            {
                UserName       = users.Nome,
                Email          = users.Email,
                EmailConfirmed = true,
                PhotoIdPath    = users.PathPhoto,
                PhoneNumber    = users.Telefone,
            };

            var result = await _userManager.CreateAsync(user, users.Password);

            if (!result.Succeeded)
            {
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }
            return(user);
        }
Example #4
0
        public IActionResult Index(Microsoft.AspNetCore.Http.IFormCollection coll)
        {
            try
            {
                using (SqlConnection sqlConnection = new SqlConnection(ConnectionSetting.CONNECTION_STRING))
                {
                    string query = string.Format("Insert into {0}(Name,Address,Contactno,Picture) Values ('{1}','{2}','{3}','{4}')", TABLE_NAME, Request.Form["personname"].ToString(), Request.Form["address"].ToString(), Request.Form["contactno"].ToString(), string.Empty);
                    using (SqlCommand command = new SqlCommand(query, sqlConnection))
                    {
                        sqlConnection.Open();
                        command.ExecuteNonQuery();
                        sqlConnection.Close();
                    }
                }
            }
            catch (Exception ex) { ViewBag.ClusterIPError = "Unable to add records. Please verify your connection.";
                                   /*Logger.Error(ex, "Index");*/ }


            string        error            = string.Empty;
            List <Person> personCollection = this.ListPersons(out error);

            if (!string.IsNullOrEmpty(error))
            {
                ViewBag.ClusterIPError = error;
            }
            return(View(personCollection));
        }
Example #5
0
        private async Task <string> Uploadfile(Microsoft.AspNetCore.Http.IFormCollection collection, string Nome)
        {
            string retcaminho = string.Empty;
            var    files      = collection.Files;

            if (files != null)
            {
                var arquivoFoto = files.FirstOrDefault();

                string nomeArquivo = string.Concat("foto_",
                                                   Nome,
                                                   DateTime.Now.Millisecond.ToString(),
                                                   ".png");

                string caminhoDestinoArquivoOriginal = string.Concat(
                    _appEnvironment.WebRootPath,
                    _config.GetValue <string>("FolderImg"),
                    nomeArquivo);

                //ajustar
                using (var stream = new FileStream(caminhoDestinoArquivoOriginal, FileMode.Create))
                {
                    await arquivoFoto.CopyToAsync(stream);
                }
                return(caminhoDestinoArquivoOriginal);
            }
            return(retcaminho);
        }
        public Request(Microsoft.AspNetCore.Http.IFormCollection postValues)
        {
            this.Columns    = new List <Column>();
            this.SortOrders = new List <SortOrder>();

            Init(postValues);
        }
Example #7
0
        public IActionResult QuizResult(Microsoft.AspNetCore.Http.IFormCollection frm)
        {
            List <User> users = UserRepository.Users;
            string      radio = frm["Question1"].ToString();

            ViewData["radio"] = radio;
            return(View(users));
        }
Example #8
0
        public async Task <IActionResult> GenerateQuestionnaireRecommendations(Microsoft.AspNetCore.Http.IFormCollection form)
        {
            //reads checked genres and tags from questionnaire stores them as comma separated values in the strings
            string genre = form["genre"];
            string tag   = form["tag"];

            string activeUserId = GetActiveUser();

            //sets genre or tag to empty string if they pass through no value
            if (genre == null)
            {
                genre = "";
            }
            if (tag == null)
            {
                tag = "";
            }

            //searches database to see if user has a previously saved questionnaire
            Questionnaire qToUpdate = _gameContext.Questionnaire.Where(q => q.UserId == activeUserId).FirstOrDefault();

            //either updates or saves new questionnaire results as appropriate
            if (qToUpdate != null)
            {
                qToUpdate.Genres = genre;
                qToUpdate.Tags   = tag;

                _gameContext.Entry(qToUpdate).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _gameContext.Update(qToUpdate);
                _gameContext.SaveChanges();
            }
            else
            {
                Questionnaire q = new Questionnaire();

                q.UserId = activeUserId;
                q.Genres = genre;
                q.Tags   = tag;
                if (ModelState.IsValid)
                {
                    _gameContext.Questionnaire.Add(q);
                    _gameContext.SaveChanges();
                }
            }

            List <Result> recommendationResultPool = await GenerateQuestionnaireResults(genre, tag);

            //sends a no results found message as viewbag if there are no results
            if (recommendationResultPool.Count > 0)
            {
                return(View("QuestionnaireResults", recommendationResultPool));
            }
            else
            {
                ViewBag.NoResults = "No results found.  Please try again.";
                return(View("QuestionnaireResults", recommendationResultPool));
            }
        }
Example #9
0
        /// <inheritdoc />
        public async Task OnAuthorizationAsync(AuthorizationFilterContext context)
        {
            if (ShouldValidate(context))
            {
                void invalidResponse()
                {
                    context.ModelState.AddModelError(CaptchaTagHelper.CaptchaSolutionFieldName, _service.ValidationMessage);
                }

                try
                {
                    if (!context.HttpContext.Request.HasFormContentType)
                    {
                        throw new MissingFieldException("The request doesn't have the form content type.");
                    }

                    string remoteIp = context.HttpContext.Connection?.RemoteIpAddress?.ToString();
                    Microsoft.AspNetCore.Http.IFormCollection form = await context.HttpContext.Request.ReadFormAsync();

                    Microsoft.Extensions.Primitives.StringValues response = form[CaptchaTagHelper.CaptchaSolutionFieldName];
                    string token = form[CaptchaTagHelper.CaptchaIdFieldName];

                    var descriptor = context?.ActionDescriptor as ControllerActionDescriptor;

                    var id         = Guid.Parse(token);
                    var parameters = new CaptchaParameters()
                    {
                        ActionName     = descriptor.ActionName,
                        ControllerName = descriptor.ControllerName,
                        IpAddress      = remoteIp,
                        CaptchaId      = id
                    };
                    await _service.ValidateAsync(parameters, response);
                }
                catch (CaptchaValidationException ex)
                {
                    if (ex.InvalidResponse)
                    {
                        _logger.LogError(ex, ex.Message);
                        invalidResponse();
                        return;
                    }
                    else
                    {
                        _logger.LogError(ex, "Unknown validation issue.");
                        invalidResponse();
                    }
                }
                catch
                {
                    _logger.LogError(new Exception(), "Unknown issue.");
                    context.Result = new BadRequestResult();
                }
            }
        }
Example #10
0
 public EmailRecieved(Microsoft.AspNetCore.Http.IFormCollection request, Uri baseUrl)
 {
     SentAt       = DateTime.UtcNow;
     SendersName  = request.Str("name");
     SendersEmail = request.Str("email");
     SendersPhone = request.Str("phone");
     SendersOrg   = request.Str("org");
     Subject      = request.Str("subject");
     Message      = request.Str("message");
     BaseUrl      = baseUrl;
 }
Example #11
0
        public IActionResult TrySearch(Microsoft.AspNetCore.Http.IFormCollection form)
        {
            form.TryGetValue("searchBox", out Microsoft.Extensions.Primitives.StringValues values);
            string value = values[0];

            if (!string.IsNullOrEmpty(value))
            {
            }

            return(Redirect($"Search?querry={value}"));
        }
Example #12
0
        public IActionResult Index(Microsoft.AspNetCore.Http.IFormCollection form)
        {
            GitHub gh           = new GitHub();
            string organization = form["searchFor"];

            if (organization != null && !organization.Equals(""))
            {
                gh.GetRepositories(form["searchFor"]);
            }
            ViewBag.Remaining = Global.remaining;
            return(View(gh));
        }
        public IActionResult RequestChange()
        {
            ViewData["where"] = ControllerName;
            if (ValidateSession())
            {
                if (Request.HasFormContentType)
                {
                    Microsoft.AspNetCore.Http.IFormCollection form = Request.Form;
                    UserChangeRequestTypes types = (UserChangeRequestTypes)Enum.Parse(typeof(UserChangeRequestTypes), form[nameof(UserChangeRequest.RequestTypes)][0]);
                    string            reason     = form[nameof(UserChangeRequest.DetailTexts)][0];
                    string            newVal     = form[nameof(UserChangeRequest.NewContent)][0];
                    UserChangeRequest request    = new UserChangeRequest()
                    {
                        DetailTexts  = reason,
                        SolverID     = "",
                        NewContent   = newVal,
                        Status       = UCRProcessStatus.NotSolved,
                        RequestTypes = types,
                        UserID       = CurrentUser.ObjectId
                    };

                    if (DataBaseOperation.CreateData(ref request) != DBQueryStatus.ONE_RESULT)
                    {
                        LW.E("AccountController->ProcessNewUCR: Create UCR Failed!");
                        return(DatabaseError(ServerAction.MyAccount_CreateChangeRequest, XConfig.Messages["CreateUCR_Failed"]));
                    }

                    InternalMessage messageAdmin = new InternalMessage()
                    {
                        _Type = GlobalMessageTypes.UCR_Created_TO_ADMIN, DataObject = request, User = CurrentUser, ObjectId = request.ObjectId
                    };
                    InternalMessage message_User = new InternalMessage()
                    {
                        _Type = GlobalMessageTypes.UCR_Created__TO_User, DataObject = request, User = CurrentUser, ObjectId = request.ObjectId
                    };
                    MessagingSystem.AddMessageProcesses(messageAdmin, message_User);

                    return(Redirect($"/{HomeController.ControllerName}/{nameof(HomeController.RequestResult)}?req=changereq&status=ok&callback=/Account/"));
                }
                else
                {
                    ViewData["cUser"] = CurrentUser.ToString();
                    return(View(new UserChangeRequest()
                    {
                        UserID = CurrentUser.ObjectId
                    }));
                }
            }
            else
            {
                return(LoginFailed("/" + ControllerName + "/" + nameof(RequestChange)));
            }
        }
Example #14
0
        public async Task <IActionResult> Editar(int id, UsuarioSistema users, Microsoft.AspNetCore.Http.IFormCollection collection)
        {
            if (id != users.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //getUser
                    var user = await _userManager.GetUserAsync(User);

                    //deleta claims do user
                    var claimsUser = await _userManager.GetClaimsAsync(user);

                    await _userManager.RemoveClaimsAsync(user, claimsUser);

                    //delete
                    var useracesso = _context.UsuarioGruposAcessos.Where(g => g.IdUsuarioSistema == id);
                    _context.UsuarioGruposAcessos.RemoveRange(useracesso);
                    await _context.SaveChangesAsync();

                    //efetua a alteração
                    user.Email       = users.Email;
                    user.PhoneNumber = users.Telefone;
                    user.UserName    = users.Nome;
                    _context.Users.Update(user);
                    _context.usuarioSistemas.Update(users);

                    //salva claims
                    InsertClaimRoles((UserCustomerModel)user, users, collection);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersExists(users.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
Example #15
0
        public IActionResult Addc(Microsoft.AspNetCore.Http.IFormCollection Livrecollection)
        {
            foreach (var item in Livrecollection)
            {
                System.Diagnostics.Debug.WriteLine($"{item.Key}:{item.Value}");
            }
            var livre = new Livre {
                Titre  = Livrecollection["titre"],
                Taille = (TailleLivre)Int32.Parse(Livrecollection["taille"])
            };

            _model.Add(livre);
            return(Ok(_model));
        }
        public string UpdateStatus(Microsoft.AspNetCore.Http.IFormCollection collection)
        {
            if (_cache.Get("DiscordActivityVersion") == null)
            {
                _cache.Set("DiscordActivityVersion", 0);
            }
            else
            {
                _cache.Set("DiscordActivityVersion", (int)_cache.Get("DiscordActivityVersion") + 1);
            }
            Thread.Sleep(100);
            Task.Run(() => UpdateActivity((int)_cache.Get("DiscordActivityVersion"), collection));

            return("Request sent!");
        }
Example #17
0
        private Dictionary <string, string> GetFormValuesForObject(
            Microsoft.AspNetCore.Http.IFormCollection formData,
            string modelName,
            int index,
            Core.FieldManager.PropertyInfoList properties)
        {
            var result = new Dictionary <string, string>();

            foreach (var item in properties)
            {
                var key = $"{modelName}[{index}].{item.Name}";
                result.Add(item.Name, formData[key]);
            }
            return(result);
        }
Example #18
0
        public ActionResult Index(Microsoft.AspNetCore.Http.IFormCollection account)
        {
            List <DepartmentSearch> departments;

            try
            {
                using (helper = new dalHelper())
                {
                    departments = helper.Search(account["lastName"], account["deptName"], account["subDeptName"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(View("~/Views/Search/Search.cshtml", departments));
        }
Example #19
0
        public async Task <IActionResult> DeleteApplicationRole(string id, Microsoft.AspNetCore.Http.IFormCollection form)
        {
            if (!String.IsNullOrEmpty(id))
            {
                ApplicationRole applicationRole = await roleManager.FindByIdAsync(id);

                if (applicationRole != null)
                {
                    IdentityResult roleRuslt = roleManager.DeleteAsync(applicationRole).Result;
                    if (roleRuslt.Succeeded)
                    {
                        return(RedirectToAction("Index"));
                    }
                }
            }
            return(View());
        }
Example #20
0
        public async Task <IActionResult> Create(int id, UsuarioSistema users, Microsoft.AspNetCore.Http.IFormCollection collection)
        {
            if (id != users.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //upload foto
                    var user = await InsertIdentity(collection, users);

                    if (user != null)
                    {
                        users.GuidId = user.Id;

                        //create usuarios
                        _context.Add(users);
                        InsertClaimRoles(user, users, collection);
                        await _context.SaveChangesAsync();

                        return(RedirectToAction(nameof(Index)));
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersExists(users.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        return(new StatusCodeResult(500));
                    }
                }
            }
            return(View(users));
        }
 public A4AMessageSummaryViewModel(Microsoft.AspNetCore.Http.IFormCollection form) : base(form)
 {
 }
        private void UpdateActivity(int VersionNumber, Microsoft.AspNetCore.Http.IFormCollection collection)
        {
            //var clientID = Environment.GetEnvironmentVariable("DISCORD_CLIENT_ID");
            string clientID = collection["ClientID"].ToString();

            if (clientID == "")
            {
                clientID = "418559331265675294";
                clientID = "636181032353136640";
            }
            var discord         = new Discord.Discord(long.Parse(clientID), (ulong)Discord.CreateFlags.Default);
            var activityManager = discord.GetActivityManager();
            var activity        = new Discord.Activity
            {
                State   = collection["State"],
                Details = collection["Details"],
                Assets  =
                {
                    LargeImage = collection["LargeImage"],
                    LargeText  = collection["LargeText"],
                    SmallImage = collection["SmallImage"],
                    SmallText  = collection["SmallText"],
                },


                Instance = true,
            };

            if (collection["timeStart"] != "")
            {
                activity.Timestamps.Start = long.Parse(collection["timeStart"]);
            }
            if (collection["timeEnd"] != "")
            {
                activity.Timestamps.End = long.Parse(collection["timeEnd"]);
            }
            ;
            if (collection["EnableParty"].ToString() == "on")
            {
                activity.Party.Id   = Guid.NewGuid().ToString();
                activity.Party.Size = new PartySize
                {
                    CurrentSize = collection["CurrentSize"] == "" ? 1 : int.Parse(collection["CurrentSize"]),
                    MaxSize     = collection["MaxSize"] == "" ? 1 : int.Parse(collection["MaxSize"])
                };
                activity.Secrets = new Discord.ActivitySecrets
                {
                    Join     = Guid.NewGuid().ToString(),
                    Match    = Guid.NewGuid().ToString(),
                    Spectate = Guid.NewGuid().ToString(),
                };
            }
            Discord.Result result1 = new Discord.Result();
            activityManager.UpdateActivity(activity, result =>
            {
                Console.WriteLine("Update Activity {0}", result);
                result1 = result;
                // Send an invite to another user for this activity.
                // Receiver should see an invite in their DM.
                // Use a relationship user's ID for this.
                // activityManager
                //   .SendInvite(
                //       364843917537050624,
                //       Discord.ActivityActionType.Join,
                //       "",
                //       inviteResult =>
                //       {
                //           Console.WriteLine("Invite {0}", inviteResult);
                //       }
                //   );
            });
            try
            {
                while (VersionNumber == (int)_cache.Get("DiscordActivityVersion"))
                {
                    discord.RunCallbacks();
                    Thread.Sleep(1000 / 10);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                discord.Dispose();
                _cache.Set("DisposeVersionCode", VersionNumber);
            }
        }
Example #23
0
        private void Init(Microsoft.AspNetCore.Http.IFormCollection postValues)
        {
            foreach (var keyValue in postValues)
            {
                string key   = keyValue.Key;
                string value = keyValue.Value;

                switch (key)
                {
                case "start":
                    this.Start = Convert.ToInt32(value);
                    break;

                case "length":
                    this.Length = Convert.ToInt32(value);
                    break;

                case "search[value]":
                    this.SearchValue = value;
                    break;

                case "search[regex]":
                    this.SearchRegex = Convert.ToBoolean(value);
                    break;

                case "draw":
                    this.Draw = Convert.ToInt32(value);
                    break;

                default:
                    if (key.StartsWith("columns"))
                    {
                        ColumnKey columnKey = new ColumnKey(key);

                        Column column = this.Columns.FirstOrDefault(x => x.Index == columnKey.Index);
                        if (column == null)
                        {
                            column = new Column()
                            {
                                Index = columnKey.Index
                            };
                            this.Columns.Add(column);
                        }

                        switch (columnKey.DataName)
                        {
                        case "data":
                            column.Data = value;
                            break;

                        case "name":
                            column.Name = value;
                            break;

                        case "searchable":
                            column.Searchable = Convert.ToBoolean(value);
                            break;

                        case "orderable":
                            column.Orderable = Convert.ToBoolean(value);
                            break;

                        case "search":
                            switch (columnKey.DataSecondName)
                            {
                            case "value":
                                column.SearchValue = value;
                                break;

                            case "regex":
                                column.SearchRegex = Convert.ToBoolean(value);
                                break;
                            }
                            break;
                        }
                    }
                    else if (key.StartsWith("order"))
                    {
                        ColumnKey columnKey = new ColumnKey(key);

                        SortOrder sortOrder = this.SortOrders.FirstOrDefault(x => x.Index == columnKey.Index);
                        if (sortOrder == null)
                        {
                            sortOrder = new SortOrder()
                            {
                                Index = columnKey.Index, Sort = SortOrderDirection.asc
                            };
                            this.SortOrders.Add(sortOrder);
                        }

                        switch (columnKey.DataName)
                        {
                        case "column":
                            sortOrder.ColumnIndex = Convert.ToInt32(value);
                            break;

                        case "dir":
                            sortOrder.Sort = (value == "desc") ? SortOrderDirection.desc : SortOrderDirection.asc;
                            break;
                        }
                    }
                    break;
                }
            }
        }
        public async Task <IActionResult> Review(int id)
        {
            Microsoft.AspNetCore.Http.IFormCollection form = Request.Form;
            if (form.ContainsKey("review-id"))
            {
                int     r_id         = Int32.Parse(form["review-id"]);
                string  reviewRole   = form["review-role"];
                string  reviewStatus = form["review-status"];
                Reviews review       = _context.Reviews.Find(r_id);
                Reviews rr           = _context.Reviews.Include(r => r.Questions).SingleOrDefault(r => r.RId == r_id);
                if (review == null)
                {
                    return(NotFound());
                }

                if (form.ContainsKey("startDate"))
                {
                    review.PeriodStart = Convert.ToDateTime(form["startDate"]);
                }
                if (form.ContainsKey("endDate"))
                {
                    review.PeriodEnd = Convert.ToDateTime(form["endDate"]);
                }
                if (form.ContainsKey("response"))
                {
                    string    q        = String.Format("select * from dbo.Responses where R_ID = {0} AND Q_ID IS NULL", review.RId);
                    Responses response = _context.Responses.FromSql(q).SingleOrDefault();
                    response.Response     = form["response"];
                    response.ResponseDate = DateTime.Now;
                }
                if (reviewRole == "Supervisor")
                {
                    if (form.ContainsKey("workflow"))
                    {
                        if (form["workflow"] == "sendack")
                        {
                            review.Status = "Ready";
                        }
                        else if (form["workflow"] == "reopen")
                        {
                            review.Status = "Open";
                        }
                        else if (form["workflow"] == "close")
                        {
                            review.Status = "Closed";
                        }
                    }
                }
                else if (reviewRole == "Employee")
                {
                    if (form.ContainsKey("workflow"))
                    {
                        if (form["workflow"] == "acknowledge")
                        {
                            review.Status = "Acknowledged";
                        }
                        else if (form["workflow"] == "return")
                        {
                            review.Status = "Open";
                        }
                    }
                }

                /*
                 * We have to loop through to find Y/N questions since there may not be a key
                 * for them (if both answers are unchecked).
                 */
                foreach (Questions qst in review.Questions)
                {
                    _logger.LogInformation("XDeal with question " + qst.QId);
                    if (qst.QtType == "Y/N")
                    {
                        string key = "ynanswer-" + qst.QId;
                        if (form.ContainsKey(key))
                        {
                            string value = form[key];
                            qst.Answer = (value == "Y") ? "1" : "0";
                        }
                        else
                        {
                            qst.Answer = null;
                        }
                    }
                }
                foreach (var key in form)
                {
                    if (key.Key.StartsWith("qanswer-"))
                    {
                        int       q_id     = Int32.Parse(key.Key.Split('-')[1]);
                        Questions question = _context.Questions.Find(q_id);
                        question.Answer = key.Value;
                    }
                }
                _context.SaveChanges();
            }
            else
            {
                return(BadRequest());
            }
            return(RedirectToRoute(new
            {
                controller = "Reviews",
                action = "Index"
            }));
        }
Example #25
0
        private async void InsertClaimRoles(UserCustomerModel user, UsuarioSistema users, Microsoft.AspNetCore.Http.IFormCollection collection)
        {
            //create relacao
            var chks = (from itens in collection.Keys
                        where itens.Contains("chk_")
                        select itens.Replace("chk_", string.Empty)).ToList();

            var lstGrupoAcesso = TempData["lstGrupoAcesso"] == null?GetListGrupoAcesso().Result : (List <GruposAcesso>)TempData["lstGrupoAcesso"];

            foreach (var item in chks)
            {
                var useracesso = new UsuarioGruposAcesso();
                useracesso.IdGrupoAcessos   = Convert.ToInt64(item);
                useracesso.IdUsuarioSistema = users.Id;
                _context.Add(useracesso);

                //salva na claims
                var itemAcesso = lstGrupoAcesso.Find(p => p.Id == Convert.ToInt64(item.ToString()));
                if (itemAcesso != null)
                {
                    await _userManager.AddClaimAsync(user,
                                                     new Claim(itemAcesso.PageAcesso, ConstantPermissions.todasPermission, itemAcesso.PageAcesso, users.GuidId));
                }
            }
        }
Example #26
0
 public FormFeature(Microsoft.AspNetCore.Http.IFormCollection form)
 {
 }
Example #27
0
        private static IEnumerable <RatesModel> ParseResultsForm(Microsoft.AspNetCore.Http.IFormCollection form)
        {
            var ret = new List <RatesModel>();

            IEnumerable <String> RatesToSave = form["item.Id"].ToString().Split(',');

            foreach (string r in RatesToSave)
            {
                int id;

                if (int.TryParse(r, out id))
                {
                    RatesModel rm = new RatesModel()
                    {
                        Id = id
                    };

                    if (!String.IsNullOrEmpty(form["rate100_" + id.ToString()]))
                    {
                        decimal val;

                        if (Decimal.TryParse(form["rate100_" + id.ToString()], out val))
                        {
                            rm.Rate100 = val;
                        }
                    }

                    if (!String.IsNullOrEmpty(form["rate600_" + id.ToString()]))
                    {
                        decimal val;

                        if (Decimal.TryParse(form["rate600_" + id.ToString()], out val))
                        {
                            rm.Rate600 = val;
                        }
                    }

                    if (!String.IsNullOrEmpty(form["rate1200_" + id.ToString()]))
                    {
                        decimal val;

                        if (Decimal.TryParse(form["rate1200_" + id.ToString()], out val))
                        {
                            rm.Rate1200 = val;
                        }
                    }

                    if (!String.IsNullOrEmpty(form["rate1700_" + id.ToString()]))
                    {
                        decimal val;

                        if (Decimal.TryParse(form["rate1700_" + id.ToString()], out val))
                        {
                            rm.Rate1700 = val;
                        }
                    }

                    if (!String.IsNullOrEmpty(form["rate5000_" + id.ToString()]))
                    {
                        decimal val;

                        if (Decimal.TryParse(form["rate5000_" + id.ToString()], out val))
                        {
                            rm.Rate5000 = val;
                        }
                    }

                    ret.Add(rm);
                }
            }

            return(ret);
        }