예제 #1
0
        //Edit Agent
        private void btEditAgent_Click(object sender, RoutedEventArgs e)
        {
            /* ApplicantViewModels applicantModel = dGridApplicants.SelectedItem as ApplicantViewModels;
             * int Index = dGridApplicants.SelectedIndex;
             * var ap = new EditApplicant(applicantModel, positionsModel, agentsModel);
             * ap.Title = "Изменить запись";
             * ap.Owner = this;
             * var result = ap.ShowDialog();
             * if (result == true)
             * {
             *  applicantService.UpdateApplicant(applicantModel);
             *  ResetCollection("ApplicantViewModel");
             *  ap.Close();
             * }           */
            AgentViewModels agentModel = dGridAgent.SelectedItem as AgentViewModels;
            int             Index      = dGridAgent.SelectedIndex;
            var             ag         = new EditAgent(agentModel);

            ag.Title = "Изменить запись";
            ag.Owner = this;
            var result = ag.ShowDialog();

            if (result == true)
            {
                agentService.UpdateAgent(agentModel);
                ResetCollection("AgentViewModel");
                ag.Close();
            }
        }
        public ActionResult Edit(int agentId)
        {
            AgentRepository repository  = new AgentRepository();
            var             agent       = repository.GetById(agentId);
            var             agentToEdit = new EditAgent {
                agentId = agent.id, agentName = agent.name
            };

            return(View(agentToEdit));
        }
        public ActionResult Edit(int agentId, EditAgent agent)
        {
            AgentRepository repository = new AgentRepository();

            Agents agentToUpdate = new Agents
            {
                id        = agent.agentId,
                Contracts = repository.GetById(agentId).Contracts,
                name      = agent.agentName
            };

            repository.Update(agentToUpdate);
            return(RedirectToAction("Index"));
        }
예제 #4
0
        public async Task <IActionResult> EditAgentProfile(string userName, EditAgent editedAgent)
        {
            if (userName == null || !ModelState.IsValid)
            {
                return(BadRequest());
            }

            var userInaspNetTable = await aspUserManager.FindByNameAsync(userName);

            var agent = agentManager
                        .GetAllWithInclude(a => a.Job, a => a.AspNetUsersId == userInaspNetTable.Id).FirstOrDefault();

            if (agent.ImagePath != editedAgent.EditAgentInfo.ImagePath)
            {
                editedAgent.EditAgentInfo.ImagePath = UploadToCloudinary.UploadImageToCloudinary(editedAgent.EditAgentInfo.ImagePath);
            }

            mapper.Map(editedAgent.EditAgentInfo, agent);

            var agentEditedSkills = skillManager
                                    .GetAll()
                                    .Where(s => editedAgent.EditSkills.ToList().Select(a => a.Name).Contains(s.Name))
                                    .Select(s => s.Id)
                                    .ToList();

            var agentSkillsInDb = agentSkillManager
                                  .GetAll()
                                  .Where(s => s.AgentId == agent.Id)
                                  .ToList();


            UpdateAgentSkills(agentEditedSkills, agentSkillsInDb);


            agentManager.Complete();

            return(Ok());
        }