Exemplo n.º 1
0
        public IActionResult Edit(int id, [Bind("id,profile_id,num_marriages,relationship_concern,social_activities,support_network")] mp_social_relationship mp_social_relationship)
        {
            if (id != mp_social_relationship.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _socialRelationshipService.UpdateSocialRelationship(mp_social_relationship);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!_socialRelationshipService.RelationshipExists(mp_social_relationship.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["profile_id"] = new SelectList(_context.mp_profile, "id", "first_name", mp_social_relationship.profile_id);
            return(View(mp_social_relationship));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("profile_id,num_marriages,relationship_concern,social_activities,support_network")] mp_social_relationship mp_social_relationship)
        {
            if (ModelState.IsValid)
            {
                await _socialRelationshipService.AddSocialRelationship(mp_social_relationship);

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["profile_id"] = new SelectList(_context.mp_profile, "id", "first_name", mp_social_relationship.profile_id);
            return(View(nameof(Index)));
        }
        public int UpdateSocialRelationship(mp_social_relationship relationship)
        {
            var existing = _context.mp_social_relationship.FirstOrDefault(m => m.id == relationship.id);

            if (existing != null)
            {
                //do update
                relationship.created_at = existing.created_at;
                relationship.created_by = existing.created_by;
                _context.Entry(existing).CurrentValues.SetValues(relationship);
                return(_context.SaveChanges());
            }
            return(0);
        }
Exemplo n.º 4
0
        public string MaritalRelationship(mp_social_relationship relationship, IFormCollection collections)
        {
            if (ModelState.IsValid)
            {
                var profile = _profileService.GetByUserId(Guid.Parse(User.FindFirstValue(ClaimTypes.NameIdentifier)));
                relationship.created_at     = DateTime.Now;
                relationship.created_by     = User.FindFirstValue(ClaimTypes.NameIdentifier);
                relationship.profile_id     = Guid.Parse(collections["profile_id"]);
                relationship.appointment_id = Guid.Parse(collections["appointment_id"]);
                _pschosocialService.AddSocialRelationship(relationship);

                List <mp_children> mp_childrens = new List <mp_children>();
                var name = collections["name"];
                //save medication
                if (name.Count > 0 & name[0].Trim() != "")
                {
                    for (int i = 0; i < name.Count; i++)
                    {
                        mp_childrens.Add(new mp_children
                        {
                            name       = name[i],
                            dob        = DateTime.Parse(collections["dob"][i]),
                            gender     = int.Parse(collections["gender"][i]),
                            profile_id = profile.id,
                            created_by = User.FindFirstValue(ClaimTypes.NameIdentifier),
                            created_at = DateTime.Now
                        });
                    }
                    if (mp_childrens.Count > 0)
                    {
                        _pschosocialService.AddChildren(mp_childrens);
                    }
                }

                return("success");
            }
            return("failure");
        }
Exemplo n.º 5
0
 public int AddSocialRelationship(mp_social_relationship relationship)
 {
     _context.Add(relationship);
     return(_context.SaveChanges());
 }
 public async Task <int> AddSocialRelationship(mp_social_relationship relationship)
 {
     _context.Add(relationship);
     return(await _context.SaveChangesAsync());
 }