public async Task <IActionResult> Edit(int id, LanguageProficiencyViewModel languageProficiency)
        {
            if (id != languageProficiency.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(languageProficiency.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LanguageProficiencyExists(languageProficiency.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            languageProficiency.loadLists(_context);
            return(View(languageProficiency));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(int id, EducationViewModel education)
        {
            if (id != education.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(education.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EducationExists(education.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            education.loadLists(_context);
            return(View(education));
        }
        public async Task <IActionResult> Edit(int id, AgentAvailabilityViewModel agentAvailability)
        {
            if (id != agentAvailability.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agentAvailability.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgentAvailabilityExists(agentAvailability.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["AgentId"] = new SelectList(_context.Agent, "Id", "Id", agentAvailability.AgentId);

            agentAvailability.loadLists(_context);
            return(View(agentAvailability));
        }
Exemple #4
0
        public async Task <IActionResult> Edit(int id, BankBranchViewModel bankBranch)
        {
            if (id != bankBranch.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(bankBranch.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BankBranchExists(bankBranch.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            bankBranch.loadLists(_context);
            return(View(bankBranch));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ActivityId,AgentId,AssignmentDate")] ActivityAssignment activityAssignment)
        {
            if (id != activityAssignment.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(activityAssignment);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ActivityAssignmentExists(activityAssignment.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ActivityId"] = new SelectList(_context.ClientRequest, "Id", "Id", activityAssignment.ActivityId);
            ViewData["AgentId"]    = new SelectList(_context.Agent, "Id", "Id", activityAssignment.AgentId);
            return(View(activityAssignment));
        }
Exemple #6
0
        public async Task <IActionResult> Edit(int id, DepartmentViewModel department)
        {
            if (id != department.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(department.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            department.loadLists(_context);
            return(View(department));
        }
        public async Task <IActionResult> Edit(int id, ProductMechanismViewModel productMechanism)
        {
            if (id != productMechanism.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(productMechanism.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductMechanismExists(productMechanism.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["ClientId"] = new SelectList(_context.Client, "Id", "Id", productMechanism.ClientId);
            ViewData["MechanismId"] = new SelectList(_context.ProductMechanism, "Id", "MechanismName", productMechanism.ProductId);
            productMechanism.loadLists(_context);
            return(View(productMechanism));
        }
Exemple #8
0
        public async Task <IActionResult> Edit(int id, OutLetViewModel outlet)
        {
            if (id != outlet.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(outlet.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OutletExists(outlet.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { id = outlet.LocationId }));
            }
            ViewBag.LocationId = outlet.LocationId;
            outlet.loadLists(_context);
            return(View(outlet));
        }
Exemple #9
0
        public async Task <IActionResult> Edit(int id, TrainingDetailsViewModel trainingDetails)
        {
            if (id != trainingDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(trainingDetails.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TrainingDetailsExists(trainingDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { id = trainingDetails.TrainingId }));
            }
            ViewBag.TrainingId = trainingDetails.TrainingId;
            return(View(trainingDetails));
        }
Exemple #10
0
        public async Task <IActionResult> Edit(int id, ClientRequestViewModel activityDetails)
        {
            if (id != activityDetails.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(activityDetails.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ActivityDetailsExists(activityDetails.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            activityDetails.loadLists(_context);
            return(View(activityDetails));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ActivityId,RatingDate,RatingTypeId,Score")] ClientRating clientRating)
        {
            if (id != clientRating.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clientRating);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientRatingExists(clientRating.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clientRating));
        }
Exemple #12
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Value")] Parameters parameters)
        {
            if (id != parameters.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(parameters);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ParametersExists(parameters.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(parameters));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,Name,Description,UserId,LastDateModified")] AgentStatus agentStatus)
        {
            if (id != agentStatus.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agentStatus);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgentStatusExists(agentStatus.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(agentStatus));
        }
Exemple #14
0
        public async Task <IActionResult> Edit(int id, MechanismViewModel mechanism)
        {
            if (id != mechanism.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mechanism.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MechanismExists(mechanism.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { id = mechanism.ClientId }));
            }
            ViewBag.ClientId     = mechanism.ClientId;
            ViewData["ClientId"] = new SelectList(_context.Client, "Id", "Id", mechanism.ClientId);
            return(View(mechanism));
        }
Exemple #15
0
        public async Task <IActionResult> Edit(int id, ClientViewModel client)
        {
            if (id != client.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    //client.ClientAppUserName = client.ClientName;
                    //var password = "******";
                    //client.ClientAppPassword = password;
                    _context.Update(client.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClientExists(client.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //if (User.IsInRole("Client"))
                //    return RedirectToAction(nameof(ClientView));
                return(RedirectToAction(nameof(Index)));
            }
            client.loadLists(_context);
            return(View(client));
        }
        public async Task <IActionResult> Edit(int id, AgentGradeViewModel agentGrade)
        {
            if (id != agentGrade.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agentGrade.GetModel());
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgentGradeExists(agentGrade.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            agentGrade.loadLists(_context);
            return(View(agentGrade));
        }
Exemple #17
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,AgentId,RatingDate,RatingType,Score")] PerformanceAppraisal performanceAppraisal)
        {
            if (id != performanceAppraisal.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(performanceAppraisal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PerformanceAppraisalExists(performanceAppraisal.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(performanceAppraisal));
        }
Exemple #18
0
        public async Task <IActionResult> Edit(int id, TrainingDefinitionViewModel trainingDefinition, IFormFile file)
        {
            if (id != trainingDefinition.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    if (file == null && file.Length == 0)
                    {
                        return(Content("file not selected"));
                    }

                    var fileName = Guid.NewGuid().ToString().Replace("-", "") + Path.GetExtension(file.FileName);

                    var filePath = Path.Combine(_appEnvironment.WebRootPath, "images\\TrainingMaterial");

                    using (var fileStream = new FileStream(Path.Combine(filePath, fileName), FileMode.Create))
                    {
                        await file.CopyToAsync(fileStream);

                        trainingDefinition.TraningMaterial = fileName;
                    }

                    _context.Update(trainingDefinition);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TrainingDefinitionExists(trainingDefinition.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["JobId"] = new SelectList(_context.JobTitle, "Id", "Name", trainingDefinition.JobId);
            //ViewData["TrainingId"] = new SelectList(_context.TrainingDetails, "Id", "Id", trainingDefinition.TrainingId);

            //ViewBag.TrainingId = trainingDefinition.TrainingId;
            trainingDefinition.loadLists(_context);
            return(View(trainingDefinition));
        }
Exemple #19
0
        public async Task <IActionResult> Edit(int id, AgentViewModel agent)
        {
            if (id != agent.Id)
            {
                return(NotFound());
            }
            Random rd       = new Random();
            Int32  passCode = rd.Next(9999);

            if (ModelState.IsValid)
            {
                try
                {
                    if (!agent.IsActive && agent.Status == 1)
                    {
                        if (agent.EmpCode == null)
                        {
                            agent.EmpCode = "A-" + passCode;
                        }
                        ////agent.AgentAppUserName = agent.FirstName + "." + agent.SurName;
                        //agent.AgentAppUserName = agent.PersonalEmail;
                        //var password = agent.SurName + passCode + "@Merkato";
                        ////var password = "******";
                        //agent.AgentAppPassword = password;
                        //var userName = agent.AgentAppUserName;
                        //var email = agent.PersonalEmail;
                        //ApplicationRole applicationRole = await _roleManager.FindByNameAsync("Agent");
                        //var role = applicationRole.Id;

                        //UserViewModel user = new UserViewModel();
                        //{
                        //    //user.UserName = userName;
                        //    user.Email = email;
                        //    user.Password = password;
                        //    user.ConfirmPassword = password;
                        //    user.ApplicationRoleId = role;
                        //}

                        //Repository repository = new Repository(_userManager, _roleManager);

                        //await repository.CreateUser(user);

                        //agent.IsActive = true;

                        _context.Update(agent.GetModel());
                        await _context.SaveChangesAsync();


                        _mailSender.SendEmail(agent.PersonalEmail, "Merkato Notification",
                                              $"Merkato has been approved your request, kindly start with the training.{Environment.NewLine} -Username :{agent.PersonalEmail} {Environment.NewLine} -Password:{agent.AgentAppPassword}"
                                              + $"{Environment.NewLine} -Application link http://173.248.135.167/Merkato"
                                              + $"{Environment.NewLine}  {Environment.NewLine} {Environment.NewLine} Merkato Team", _context, false);
                    }
                    else
                    {
                        _context.Update(agent.GetModel());
                        await _context.SaveChangesAsync();
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgentExists(agent.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                //if (User.IsInRole("Agent"))
                //    return RedirectToAction(nameof(AgentView));
                return(RedirectToAction(nameof(Index)));
            }
            agent.loadLists(_context);
            return(View(agent));
        }