Ejemplo n.º 1
0
        public async Task DeleteCountryAsync(Guid id)
        {
            var entity = await _context.Countries.FirstAsync(p => p.Id == id);

            _context.Remove(entity);
            await _context.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task CreateIssueAsync(IssueCreateItem item)
        {
            var issue = new Issue
            {
                Id              = Guid.NewGuid(),
                AssignedToId    = item.AssignedToId,
                AreaId          = item.AreaId,
                CreationTime    = DateTime.Now,
                IssueDescripton = item.Descripton,
                Title           = item.Title,
                IssueTypeId     = item.IssueTypeId,
            };

            if (item.Attachments != null)
            {
                foreach (var attachment in item.Attachments)
                {
                    var ia = new IssueAttachment {
                        Id = Guid.NewGuid(), IssueId = issue.Id, Content = attachment
                    };
                    issue.Attachments.Add(ia);
                }
            }
            await _context.Issues.AddAsync(issue);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 3
0
        public async Task DeleteAsync(Guid id)
        {
            var dbItem = await _context.Employees.FirstAsync(p => p.Id == id);

            _context.Employees.Remove(dbItem);

            await _context.SaveChangesAsync();
        }
        public async Task <IActionResult> Create([Bind("EntryID,Date,Text")] Entry entry)
        {
            if (ModelState.IsValid)
            {
                _context.Add(entry);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(entry));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("DiaryID,Title,CreatedDate")] Diary diary)
        {
            if (ModelState.IsValid)
            {
                _context.Add(diary);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(diary));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult <Note> > Post(Note note)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _db.Notes.Add(note);
            await _db.SaveChangesAsync();

            return(Ok(note));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> Add(Note note)
        {
            if (ModelState.IsValid)
            {
                _db.Notes.Add(note);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            else
            {
                return(RedirectToAction(nameof(Add)));
            }
        }
Ejemplo n.º 8
0
        public async Task SaveEntries(int entryId, string content)
        {
            bool saveSuccesful;

            using (var context = new DiaryContext()) {
                var entry = await context.Entries.FirstOrDefaultAsync(b => b.Id == entryId);

                entry.Content = content;
                await context.SaveChangesAsync();

                saveSuccesful = entry != null;
            }
            await Clients.Caller.EntriesSaved(saveSuccesful);
        }
Ejemplo n.º 9
0
        public async Task Register(string username, string password)
        {
            bool registrationSuccessful;

            using (var context = new DiaryContext()) {
                context.Users.Add(new User {
                    Username = username,
                    Password = password,
                    Entries  = null,
                });
                await context.SaveChangesAsync();

                var user = await context.Users.FirstOrDefaultAsync(b => b.Username == username);

                registrationSuccessful = user != null;
            }
            await Clients.Caller.RegistrationDone(registrationSuccessful);
        }