예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("IdNomination,NominationName")] Nominations nominations)
        {
            if (id != nominations.IdNomination)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(nominations);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!NominationsExists(nominations.IdNomination))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(nominations));
        }
예제 #2
0
        public ActionResult Create([Bind(Include = "nominationID,award,recognizor,nomineeID,recognitionDate,description")] Nominations nominations)
        {
            if (ModelState.IsValid)
            {
                Guid memberID;
                Guid.TryParse(User.Identity.GetUserId(), out memberID);
                nominations.recognizor      = memberID;
                nominations.recognitionDate = DateTime.Now;
                db.Nominations.Add(nominations);
                db.SaveChanges();
                var recognizorObject    = db.UserDetails.Find(nominations.recognizor);
                var recipientObject     = db.UserDetails.Find(nominations.nomineeID);
                var recognizorFirstName = recognizorObject.firstName;
                var recognizorLastName  = recognizorObject.lastName;
                var recipientFirstName  = recipientObject.firstName;
                var recipientLastName   = recipientObject.lastName;
                var recepientEmail      = recipientObject.email;
                var valueName           = nominations.award;
                var valueDescription    = nominations.description;

                var message = "Hello" + " " + recipientFirstName + " " + recipientLastName + ", \n\nCongratulations! ";
                message += "You have been recognized by " + recognizorFirstName + " " + recognizorLastName + " for exemplifying one of Centric's core values." + " ";
                message += recognizorFirstName + "\nrecognized you for demonstrating " + valueName + " in the workplace.";
                message += "\n\nOn behalf of Centric,\nthank you for all your hard work!";

                MailMessage myMessage = new MailMessage();
                MailAddress from      = new MailAddress("*****@*****.**", "Centric Values System");
                myMessage.From = from;
                myMessage.To.Add(recepientEmail);
                myMessage.Subject = "Centric Core Values Recognition";
                myMessage.Body    = message;
                try
                {
                    SmtpClient smtp = new SmtpClient();
                    smtp.Host = "smtp.gmail.com";
                    smtp.Port = 587;
                    smtp.UseDefaultCredentials = false;
                    smtp.Credentials           = new System.Net.NetworkCredential("centricvalues", "Values2020!");
                    smtp.EnableSsl             = true;
                    //smtp.Send(myMessage);
                    TempData["mailError"] = message;
                    return(View("mailError"));
                }
                catch (Exception ex)
                {
                    TempData["mailError"] = ex.Message;
                    return(View("mailError"));
                }
            }

            string     userID    = User.Identity.GetUserId();
            SelectList employees = new SelectList(db.UserDetails, "ID", "fullName");

            employees         = new SelectList(employees.Where(x => x.Value != userID).ToList(), "Value", "Text");
            ViewBag.nomineeID = employees;

            //ViewBag.nomineeID = new SelectList(db.UserDetails, "ID", "fullName");

            return(View(nominations));
        }
예제 #3
0
        private void SharedArrange()
        {
            // Arrange
            processCMONominationsCommand = this.CreateProcessCMONominationsCommand();
            this.request = this.fixture.Create <Nominations>();

            // Setup Party Match
            this.matchPartyResponse = this.fixture.Create <RACQAZ.Channel.CMO.NominationMgmt.v1.API.MatchParty.Models.Response.MatchPartyResponse>();
            matchPartyResponse.Result.MatchPercent = "100";
            matchPartyResponse.DataArea.Party.PersonStatusIndicator = "Alive";
            matchPartyResponse.DataArea.Party.IdentifierIdentification.First().IdentificationSchemeAgencyIdentifier = "APTTUS";
            mockPartyMatchClient.Setup(mc => mc.MatchPartyAsync(It.IsAny <MatchPartyRequest>())).Returns(Task.FromResult(matchPartyResponse));

            // Setup Create Quote
            var createQuoteResponse = this.fixture.Create <ApttusQuote>();

            createQuoteResponse.Result.ResultCode = MappingConstants.Success;
            mockQuoteManagementClient.Setup(m => m.CreateQuoteAsync(It.IsAny <ApttusQuote>())).Returns(Task.FromResult(createQuoteResponse));

            // Setup finalise Quote
            var finaliseQuoteResponse = this.fixture.Create <ApttusCartResponse>();

            finaliseQuoteResponse.Result.ResultCode = MappingConstants.Success;
            mockCartManagementClient.Setup(m => m.FinalizeQuotebyCartIdAsync(It.IsAny <ApttusCartRequest>())).Returns(Task.FromResult(finaliseQuoteResponse));

            nominationSentToQueue = null;
            mockServiceBusSender.Setup(m => m.SendMessage(It.IsAny <Nominations>())).Callback <Nominations>(n => nominationSentToQueue = n);
        }
예제 #4
0
        public async Task <IActionResult> PutNomination(int id, Nominations nomination)
        {
            if (id != nomination.Id)
            {
                return(BadRequest());
            }

            _context.Entry(nomination).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NominationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #5
0
        private void SetNomineeIdentifiers(AwardType awardType)
        {
            var nominationsByNominee = Nominations
                                       .Where(n => n.AwardType == awardType)
                                       .Select((n, i) => new { Index = i, Nomination = n })
                                       .GroupBy(x => x.Nomination.Nominee);

            foreach (var group in nominationsByNominee)
            {
                var nomineeIndexes   = group.Select(x => x.Index).ToList();
                var votingIdentifier = NomineeVotingIdentifier.Create(nomineeIndexes);

                foreach (var item in group)
                {
                    var nomination = item.Nomination;

                    if (nomination.VotingIdentifier == votingIdentifier)
                    {
                        continue;
                    }

                    nomination.SetVotingIdentifier(votingIdentifier);
                }
            }
        }
        private async Task <ApttusQuote> CreateQuote(Nominations request, PartyManagement.Response.IdentifierIdentificationType partyIdentifierIdentification)
        {
            if (request != null && partyIdentifierIdentification != null)
            {
                try
                {
                    var mappedQuoteRequest = MappingHelper.Map(createQuoteMapper, new Tuple <Nominations, PartyManagement.Response.IdentifierIdentificationType>(request, partyIdentifierIdentification), "Mapping to a Create Quote Request");

                    var createQuoteResponse = await quoteManagementClient.CreateQuoteAsync(mappedQuoteRequest).ConfigureAwait(false);

                    if (createQuoteResponse?.Result?.ResultCode != MappingConstants.Success)
                    {
                        var errorData = createQuoteResponse?.Result?.Message?.Errors?.FirstOrDefault();

                        request.DataArea.Nomination.StatusCode        = MappingConstants.Error;
                        request.DataArea.Nomination.StatusDescription = $"Error encountered while creating the quote in Apttus. System: {errorData?.System}, Code:{errorData?.Code}, Description:{errorData?.Description} - {errorData?.ExtraDetail}";

                        return(null);
                    }

                    return(createQuoteResponse);
                }
                catch (Exception ex)
                {
                    request.DataArea.Nomination.StatusCode        = MappingConstants.Error;
                    request.DataArea.Nomination.StatusDescription = ex.Message;
                }
            }
            return(null);
        }
예제 #7
0
        public void RemoveNomination(int nominationId)
        {
            var nomination = Nominations.FirstOrDefault(n => n.Id == nominationId);

            if (nomination == null)
            {
                throw new ArgumentException(nameof(nominationId));
            }

            var removed = _nominations.Remove(nomination);

            if (!removed)
            {
                return;
            }

            SetNomineeIdentifiers();

            MarkAsDirty(
                $@"Removed {nomination.NominatorName.RawNameText}'s nomination for {nomination.NomineeName.FullName}");

            if (!GetNominationsForNominee(nomination.AwardType, nomination.Nominee).Any())
            {
                UnselectAwardWinner(nomination.AwardType, nomination.Nominee);
            }
        }
        private async Task FinaliseQuote(Nominations request, ApttusQuote newQuote)
        {
            try
            {
                if (newQuote == null)
                {
                    return;
                }

                var apttusCartRequest = MappingHelper.Map(createQuoteRequestToFinaliseQuoteMapper, newQuote, "Mapping to a Finalise Quote Request");

                var apttusCartResponse = await cartManagementClient.FinalizeQuotebyCartIdAsync(apttusCartRequest).ConfigureAwait(false);

                if (apttusCartResponse?.Result?.ResultCode == MappingConstants.Success)
                {
                    request.DataArea.Nomination.StatusDescription = $"Apttus product created, policy ID: {apttusCartResponse?.DataArea?.ProductQuoteReference?.FirstOrDefault()?.PolicyNumber}";
                    request.DataArea.Nomination.StatusCode        = MappingConstants.Success;

                    await serviceBusSender.SendMessage(request).ConfigureAwait(false);
                }
                else
                {
                    var errorData = apttusCartResponse?.Result?.Message?.Errors?.FirstOrDefault();
                    request.DataArea.Nomination.StatusCode        = MappingConstants.Error;
                    request.DataArea.Nomination.StatusDescription = $"Error encountered while finalising the quote in Apttus. System: {errorData?.System}, Code:{errorData?.Code}, Description:{errorData?.Description} - {errorData?.ExtraDetail}";
                }
            }
            catch (Exception ex)
            {
                request.DataArea.Nomination.StatusCode        = MappingConstants.Error;
                request.DataArea.Nomination.StatusDescription = ex.Message;
            }
        }
예제 #9
0
        public ActionResult DeleteConfirmed(int id)
        {
            Nominations nominations = db.Nominations.Find(id);

            db.Nominations.Remove(nominations);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> ExecuteAsync(Nominations request, CancellationToken cancellationToken)
        {
            _ = request ?? throw new ArgumentNullException(nameof(request));

            LogRequest(request);

            PartyManagement.Response.IdentifierIdentificationType partyResponse = null;

            var matchPartyResult = await MatchParty(request).ConfigureAwait(false);

            if (matchPartyResult.IsFullMatch())
            {
                if (matchPartyResult.IsPartyDead())
                {
                    await HandleError($"(Party match successful, party is deceased) (D365 Party ID: {matchPartyResult.GetD365Id()})(Apttus ID: {matchPartyResult.GetApttusId()})", request);

                    return(new OkResult());
                }
                else
                {
                    // just mapping?
                    partyResponse = ProcessPartyDataFullMatch(matchPartyResult);
                }
            }
            else if (matchPartyResult.IsPartialMatch())
            {
                await HandleError("Party match failure - Matching returned 'partial'", request);

                return(new OkResult());
            }
            else if (matchPartyResult.IsNoMatch())
            {
                partyResponse = await CreateParty(request).ConfigureAwait(false);
            }

            if (request.DataArea.Nomination.StatusCode == MappingConstants.Error)
            {
                Log.Information($"Validate Nomination to see if required fields exist");
                string validationResult = nominationValidatior.Validate(request.DataArea.Nomination);

                if (validationResult != null)
                {
                    await Reject(validationResult, request);
                }
                else
                {
                    await HandleError(null, request);
                }

                return(new OkResult());
            }

            var newQuote = await CreateQuote(request, partyResponse).ConfigureAwait(false);

            await FinaliseQuote(request, newQuote).ConfigureAwait(false);

            return(new OkResult());
        }
예제 #11
0
        public bool HasNominationsForAward(AwardType awardType)
        {
            if (awardType == null)
            {
                throw new ArgumentNullException(nameof(awardType));
            }

            return(Nominations.Any(n => n.AwardType == awardType));
        }
        private async Task HandleError(string errorDescription, Nominations request, string statusCode = MappingConstants.Error)
        {
            Log.Information(errorDescription);

            request.DataArea.Nomination.StatusCode        = statusCode;
            request.DataArea.Nomination.StatusTimeStamp   = DateTime.Now.ToLocalTime().ToString();
            request.DataArea.Nomination.StatusDescription = errorDescription ?? request.DataArea.Nomination.StatusDescription;

            await serviceBusSender.SendMessage(request).ConfigureAwait(false);
        }
예제 #13
0
        public async Task <IActionResult> Create([Bind("IdNomination,NominationName")] Nominations nominations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(nominations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(nominations));
        }
예제 #14
0
 public ActionResult Edit([Bind(Include = "nominationID,award,recognizor,nomineeID,recognitionDate")] Nominations nominations)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nominations).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.recognizor = new SelectList(db.UserDetails, "ID", "email", nominations.recognizor);
     ViewBag.nomineeID  = new SelectList(db.UserDetails, "ID", "email", nominations.nomineeID);
     return(View(nominations));
 }
예제 #15
0
        public async Task <ActionResult <Nominations> > PostNomination([FromForm] Nominations nomination)
        {
            nomination.Active      = true;
            nomination.DateAdded   = DateTime.UtcNow;
            nomination.DateUpdated = DateTime.UtcNow;
            nomination.UpdatedBy   = 1; //TODO: chaneg user Id's in future to user
            nomination.CreatedBy   = 1; //TODO: chaneg user Id's in future to user

            _context.Nominations.Add(nomination);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetNomination", new { id = nomination.Id }, nomination));
        }
예제 #16
0
        public IReadOnlyList <Nomination> GetNominationsForNominee(AwardType awardType, Person nominee)
        {
            if (awardType == null)
            {
                throw new ArgumentNullException(nameof(awardType));
            }
            if (nominee == null)
            {
                throw new ArgumentNullException(nameof(nominee));
            }

            return(Nominations.Where(n => n.Nominee == nominee && n.AwardType == awardType).ToList());
        }
예제 #17
0
        // GET: Nominations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Nominations nominations = db.Nominations.Find(id);

            if (nominations == null)
            {
                return(HttpNotFound());
            }
            return(View(nominations));
        }
예제 #18
0
        // GET: Nominations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Nominations nominations = db.Nominations.Find(id);

            if (nominations == null)
            {
                return(HttpNotFound());
            }
            ViewBag.recognizor = new SelectList(db.UserDetails, "ID", "email", nominations.recognizor);
            ViewBag.nomineeID  = new SelectList(db.UserDetails, "ID", "email", nominations.nomineeID);
            return(View(nominations));
        }
 private async Task <MatchPartyResponse.MatchPartyResponse> MatchParty(Nominations request)
 {
     if (request != null)
     {
         try
         {
             var mappedRequest = MappingHelper.Map(partyMatchMapper, request, "Mapping to a Match Party Request");
             return(await partyMatchClient.MatchPartyAsync(mappedRequest).ConfigureAwait(false));
         }
         catch (Exception ex)
         {
             request.DataArea.Nomination.StatusCode        = MappingConstants.Error;
             request.DataArea.Nomination.StatusDescription = ex.Message;
         }
     }
     return(null);
 }
예제 #20
0
        public IReadOnlyList <Person> GetNomineesForAward(AwardType awardType, bool excludeWinners)
        {
            if (awardType == null)
            {
                throw new ArgumentNullException(nameof(awardType));
            }

            var winners = excludeWinners
                ? GetWinnersForAwardType(awardType).Select(w => w.Person)
                : Enumerable.Empty <Person>();

            return(Nominations
                   .Where(n => n.AwardType == awardType)
                   .Select(n => n.Nominee)
                   .Except(winners)
                   .ToList());
        }
예제 #21
0
        public void UpdateNomineeName(Person nominee, PersonName newNomineeName)
        {
            if (nominee == null)
            {
                throw new ArgumentNullException(nameof(nominee));
            }
            if (newNomineeName == null)
            {
                throw new ArgumentNullException(nameof(newNomineeName));
            }
            if (!newNomineeName.IsValid)
            {
                throw new ArgumentException(nameof(newNomineeName));
            }

            if (nominee.Name == newNomineeName)
            {
                return;
            }

            var nominations = Nominations.Where(n => n.Nominee == nominee);
            var updated     = false;

            foreach (var nomination in nominations)
            {
                nomination.UpdateNomineeName(newNomineeName);
                updated = true;
            }

            if (!updated)
            {
                return;
            }

            SetNomineeIdentifiers();

            var awardWinner = AwardWinners.FirstOrDefault(w => w.Person == nominee);

            if (awardWinner != null)
            {
                awardWinner.UpdateAwardWinnerName(newNomineeName);
            }

            MarkAsDirty($@"Updated nominee name from {nominee.Name.FullName} to {newNomineeName.FullName}");
        }
예제 #22
0
        public void UpdateNomineeEmailAddress(Person nominee, EmailAddress newEmailAddress)
        {
            if (nominee == null)
            {
                throw new ArgumentNullException(nameof(nominee));
            }
            if (newEmailAddress == null)
            {
                throw new ArgumentNullException(nameof(newEmailAddress));
            }
            if (!newEmailAddress.IsValid)
            {
                throw new ArgumentException(nameof(newEmailAddress));
            }

            if (nominee.EmailAddress == newEmailAddress)
            {
                return;
            }

            var nominations = Nominations.Where(n => n.Nominee == nominee);
            var updated     = false;

            foreach (var nomination in nominations)
            {
                nomination.UpdateNomineeEmailAddress(newEmailAddress);
                updated = true;
            }

            if (!updated)
            {
                return;
            }

            SetNomineeIdentifiers();

            var awardWinner = AwardWinners.FirstOrDefault(w => w.Person == nominee);

            if (awardWinner != null)
            {
                awardWinner.UpdateAwardWinnerEmailAddress(newEmailAddress);
            }

            MarkAsDirty($@"Updated nominee email address from {nominee.EmailAddress.Value} to {newEmailAddress.Value}");
        }
예제 #23
0
        public void UpdateNomineeOfficeLocation(Person nominee, OfficeLocation newOfficeLocation)
        {
            if (nominee == null)
            {
                throw new ArgumentNullException(nameof(nominee));
            }
            if (newOfficeLocation == null)
            {
                throw new ArgumentNullException(nameof(newOfficeLocation));
            }
            if (!OfficeLocation.ValidEmployeeOfficeLocations.Contains(newOfficeLocation))
            {
                throw new ArgumentException(nameof(newOfficeLocation));
            }

            var nominations = Nominations.Where(n => n.Nominee == nominee);
            var updated     = false;

            foreach (var nomination in nominations)
            {
                nomination.UpdateNomineeOfficeLocation(newOfficeLocation);
                updated = true;
            }

            if (!updated)
            {
                return;
            }

            SetNomineeIdentifiers();

            var awardWinner = AwardWinners.FirstOrDefault(w => w.Person == nominee);

            if (awardWinner != null)
            {
                awardWinner.UpdateAwardWinnerOfficeLocation(newOfficeLocation);
            }

            MarkAsDirty(
                $@"Updated nominee {nominee.Name.FullName}'s office location from {nominee.OfficeLocation.Name} to {
                        newOfficeLocation.Name
                    }");
        }
예제 #24
0
        public void UpdateNominationWriteUp(int nominationId, NominationWriteUp newWriteUp)
        {
            if (newWriteUp == null)
            {
                throw new ArgumentNullException(nameof(newWriteUp));
            }
            if (!newWriteUp.IsValid)
            {
                throw new ArgumentException(nameof(newWriteUp));
            }

            var nomination = Nominations.FirstOrDefault(n => n.Id == nominationId);

            if (nomination == null)
            {
                throw new ArgumentException(nameof(nominationId));
            }

            nomination.UpdateWriteUp(newWriteUp);
            MarkAsDirty($@"Updated a nomination write-up for {nomination.NomineeName}");
        }
        public async Task <IActionResult> Import(IFormFile fileExcel)
        {
            if (ModelState.IsValid)
            {
                if (fileExcel != null)
                {
                    using (var stream = new FileStream(fileExcel.FileName, FileMode.Create))
                    {
                        await fileExcel.CopyToAsync(stream);

                        using (XLWorkbook workBook = new XLWorkbook(stream, XLEventTracking.Disabled))
                        {
                            foreach (IXLWorksheet worksheet in workBook.Worksheets)
                            {
                                ParticipantTypes newtype;
                                var t = (from type in _context.ParticipantTypes where type.ParticipantType.Contains(worksheet.Name) select type).ToList();
                                if (t.Count > 0)
                                {
                                    newtype = t[0];
                                }

                                else
                                {
                                    newtype = new ParticipantTypes();
                                    newtype.ParticipantType = worksheet.Name;
                                    _context.ParticipantTypes.Add(newtype);
                                }
                                //перегляд усіх рядків
                                foreach (IXLRow row in worksheet.RowsUsed().Skip(1))
                                {
                                    try
                                    {
                                        //участник
                                        Participants participant = new Participants();
                                        var          p           = (from part in _context.Participants where part.ParticipantName == row.Cell(1).Value.ToString() select part).ToList();
                                        if (p.Count > 0)
                                        {
                                            participant = p[0];
                                        }
                                        else
                                        {
                                            participant.ParticipantName = row.Cell(1).Value.ToString();
                                            participant.ParticipantDate = Convert.ToDateTime(row.Cell(2).Value.ToString());
                                            participant.Biography       = row.Cell(3).Value.ToString();

                                            //участник -> город
                                            Cities newcity;
                                            var    c = (from city in _context.Cities where city.CityName.Contains(row.Cell(4).Value.ToString()) select city).ToList();
                                            if (c.Count > 0)
                                            {
                                                newcity = c[0];
                                            }
                                            else
                                            {
                                                newcity             = new Cities();
                                                newcity.CityName    = row.Cell(4).Value.ToString();
                                                newcity.Description = "Imported from file.";
                                                _context.Cities.Add(newcity);
                                            }

                                            participant.IdRepresentedCityNavigation = newcity;
                                            participant.IdParticipantTypeNavigation = newtype;
                                            _context.Participants.Add(participant);
                                        }

                                        //участие
                                        Participations participation = new Participations();
                                        var            pt            = (from parts in _context.Participations where parts.IdParticipantNavigation.ParticipantName == row.Cell(1).Value.ToString() select parts).ToList();
                                        if (pt.Count > 0)
                                        {
                                            participation = pt[0];
                                        }
                                        else
                                        {
                                            //песня
                                            Songs song = new Songs();
                                            var   s    = (from songs in _context.Songs where song.SongName == row.Cell(5).Value.ToString() select songs).ToList();
                                            if (s.Count > 0)
                                            {
                                                song = s[0];
                                            }
                                            else
                                            {
                                                song.SongName = row.Cell(5).Value.ToString();
                                                string   myString = row.Cell(6).Value.ToString();
                                                double   d        = double.Parse(myString);
                                                DateTime dt       = DateTime.FromOADate(d);
                                                song.Duration = new TimeSpan(dt.Hour, dt.Minute, dt.Second);
                                                _context.Songs.Add(song);
                                            }

                                            //участие -> год
                                            Years newyear;
                                            var   y = (from year in _context.Years where year.YearOfContest == int.Parse(row.Cell(7).Value.ToString()) select year).ToList();
                                            if (y.Count > 0)
                                            {
                                                newyear = y[0];
                                            }
                                            else
                                            {
                                                newyear = new Years();
                                                newyear.YearOfContest = Convert.ToInt32(row.Cell(7).Value);
                                                newyear.Slogan        = "Slogan";
                                                newyear.Stage         = "Stage";
                                                foreach (var city in _context.Cities)
                                                {
                                                    if (city.CityName == "POLIGON")
                                                    {
                                                        newyear.IdHostCityNavigation = city;
                                                        break;
                                                    }
                                                }
                                                _context.Years.Add(newyear);
                                            }

                                            //участие -> номинация
                                            Nominations newnomination;
                                            var         n = (from nomination in _context.Nominations where nomination.NominationName.Contains(row.Cell(8).Value.ToString()) select nomination).ToList();
                                            if (n.Count > 0)
                                            {
                                                newnomination = n[0];
                                            }
                                            else
                                            {
                                                newnomination = new Nominations();
                                                newnomination.NominationName = row.Cell(8).Value.ToString();
                                                _context.Nominations.Add(newnomination);
                                            }


                                            participation.IdParticipantNavigation   = participant;
                                            participation.IdSongNavigation          = song;
                                            participation.IdYearOfContestNavigation = newyear;
                                            participation.IdNominationNavigation    = newnomination;
                                            participation.Place = Convert.ToInt32(row.Cell(9).Value);

                                            _context.Participations.Add(participation);
                                        }
                                    }
                                    catch
                                    {
                                        RedirectToAction("ErrorOpen", "Home");
                                    }
                                }
                            }
                        }
                    }
                }

                await _context.SaveChangesAsync();
            }
            return(RedirectToAction(nameof(Index)));
        }
        private async Task <PartyManagement.Response.IdentifierIdentificationType> CreateParty(Nominations request)
        {
            if (request != null)
            {
                try
                {
                    var mappedRequest = MappingHelper.Map(createPartyMapper, request, "Mapping to a Create Party Request");

                    var createPartyResponse = await partyManagementClient.CreateNewPartyAsync(mappedRequest).ConfigureAwait(false);

                    if (createPartyResponse?.PartyResponse?.Result?.ResultCode != MappingConstants.Success)
                    {
                        var errorData = createPartyResponse?.PartyResponse?.Message?.Errors?.FirstOrDefault();

                        request.DataArea.Nomination.StatusCode        = MappingConstants.Error;
                        request.DataArea.Nomination.StatusDescription = $"Error encountered while creating the new party. System: {errorData?.System}, Code:{errorData?.Code}, Description:{errorData?.Description} - {errorData?.ExtraDetail}";
                    }

                    return(createPartyResponse?.PartyResponse?.Result?.Party?.IdentifierIdentification?.FirstOrDefault(x => string.Equals(x?.IdentificationSchemeAgencyIdentifier, MappingConstants.ApttusAgencyIdentifier, StringComparison.OrdinalIgnoreCase)));
                }
                catch (Exception ex)
                {
                    request.DataArea.Nomination.StatusCode        = MappingConstants.Error;
                    request.DataArea.Nomination.StatusDescription = ex.Message;
                }
            }
            return(null);
        }
 private async Task Reject(string statusExtraDetail, Nominations request)
 {
     request.DataArea.Nomination.StatusExtraDetail = statusExtraDetail;
     await HandleError($"Append, with a leading space, on to any existing value: (Validation error {statusExtraDetail})", request, MappingConstants.Rejected);
 }
예제 #28
0
 private IEnumerable <Nomination> GetNominationsByAwardType(AwardType awardType)
 {
     return(Nominations.Where(n => n.AwardType == awardType));
 }
 private static void LogRequest(Nominations request)
 {
     Log.Information($"Initiate CMO Sequence");
     Log.Debug($"\n{JsonConvert.SerializeObject(request, Formatting.Indented)}");
 }
예제 #30
0
 public async Task <IActionResult> ProcessCMONominations(
     [FromServices] IProcessCMONominationsCommand command,
     [FromBody] Nominations request) => await command.ExecuteAsync(request).ConfigureAwait(false);