Esempio n. 1
0
        public string Post([FromBody] Users value)
        {
            if (!dbContext.Users.Any(user => user.Login.Equals(value.Login)))
            {
                Users user = new Users();
                user.Name     = value.Name;
                user.Login    = value.Login;
                user.Password = value.Password;
                user.Phone    = value.Phone;
                user.Email    = value.Email;

                try
                {
                    dbContext.Add(user);
                    dbContext.SaveChanges();
                    return(JsonConvert.SerializeObject("User has been registered!"));
                }
                catch (Exception e)
                {
                    return(JsonConvert.SerializeObject(e.Message));
                }
            }
            else
            {
                return(JsonConvert.SerializeObject("User is existing!"));
            }
        }
        public async Task <IActionResult> Create([Bind("ProjectId,MemberId")] ProjectMember projectMember)
        {
            if (ModelState.IsValid)
            {
                _context.Add(projectMember);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MemberId"]  = new SelectList(_context.AllUsers, "Id", "Name", projectMember.MemberId);
            ViewData["ProjectId"] = new SelectList(_context.Projects, "Id", "Description", projectMember.ProjectId);
            return(View(projectMember));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("SpecialtyId,UserId")] SpecialtyUser specialtyUser)
        {
            if (ModelState.IsValid)
            {
                _context.Add(specialtyUser);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["SpecialtyId"] = new SelectList(_context.Specialties, "Id", "Name", specialtyUser.SpecialtyId);
            ViewData["UserId"]      = new SelectList(_context.AllUsers, "Id", "Name", specialtyUser.UserId);
            return(View(specialtyUser));
        }
        public void Post([FromBody] Members value)
        {
            Members member = new Members();

            member.EventId = value.EventId;
            member.UId     = value.UId;

            try
            {
                dbContext.Add(member);
                dbContext.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }
Esempio n. 5
0
        public void Post([FromBody] Events value)
        {
            Events events = new Events();

            events.CId         = value.CId;
            events.Title       = value.Title;
            events.Description = value.Description;
            events.Date        = value.Date;

            try
            {
                dbContext.Add(events);
                dbContext.SaveChanges();
            }
            catch (Exception e)
            {
            }
        }