Exemplo n.º 1
0
        public IActionResult Index(CharterContent charter)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", GetModel()));
            }
            Domain.AddOrUpdateCharter(charter);

            return(View("Index", GetModel()));
        }
Exemplo n.º 2
0
        public IActionResult Details(CharterContent charter, [FromServices] IMapper mapper)
        {
            if (!ModelState.IsValid)
            {
                return(View(GetMeetupDetailModel(charter.MeetupId.Value, mapper)));
            }
            Domain.AddOrUpdateCharter(charter);

            return(View(GetMeetupDetailModel(charter.MeetupId.Value, mapper)));
        }
Exemplo n.º 3
0
        public int AddOrUpdateCharter(CharterContent charter)
        {
            if (charter.Id == 0)
            {
                _context.CharterContents.Add(charter);
            }
            else
            {
                charter.CreatedAt = _context.CharterContents.AsNoTracking().First(x => x.Id == charter.Id).CreatedAt;
                charter.UpdatedAt = DateTime.UtcNow;
                _context.Update(charter);
            }
            _context.SaveChanges();
            IOrderedQueryable <CharterContent> qcharters = GetCharterFor(charter.MeetupId, true, false, false);

            List <CharterContent> charters = qcharters.ThenByDescending(x => x.UpdatedAt).ToList();

            for (int i = 0; i < charters.Count(); i++)
            {
                charters[i].Position = i + 1;
            }
            _context.SaveChanges();
            return(charter.Id);
        }