public async Task <ActionResult <relationship> > PostRelationship(relationship relationship) { _context.relationship.Add(relationship); await _context.SaveChangesAsync(); return(CreatedAtAction("Getrelationship", new { id = relationship.relationshipId }, relationship)); }
public async Task <IActionResult> PutRelationship(int id, relationship relationship) { if (id != relationship.relationshipId) { return(BadRequest()); } _context.Entry(relationship).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!relationshipExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public static relationship NewRelationship(PropertyAndValue pavcIn) { relationship r = null; if (pavcIn.pValues[(int)CecilConst.PropertyName.Name] == null) { throw new ArgumentNullException(CecilConst.PropertyName.Name.ToString()); } if (pavcIn.pValues[(int)CecilConst.PropertyName.FullName] == null) { throw new ArgumentNullException(CecilConst.PropertyName.FQName.ToString()); } if (pavcIn.pValues[(int)CecilConst.PropertyName.ArchiMateElementType] == null) { throw new ArgumentNullException(CecilConst.PropertyName.ArchiMateElementType.ToString()); } if (pavcIn.pValues[(int)CecilConst.PropertyName.APIType] == null) { throw new ArgumentNullException(CecilConst.PropertyName.APIType.ToString()); } if (pavcIn.pValues[(int)CecilConst.PropertyName.SourceIdentifier] == null) { throw new ArgumentNullException(CecilConst.PropertyName.SourceIdentifier.ToString()); } if (pavcIn.pValues[(int)CecilConst.PropertyName.TargetIdentifier] == null) { throw new ArgumentNullException(CecilConst.PropertyName.TargetIdentifier.ToString()); } string label = pavcIn.pValues[(int)CecilConst.PropertyName.Name]; string fullname = pavcIn.pValues[(int)CecilConst.PropertyName.FullName]; string type = pavcIn.pValues[(int)CecilConst.PropertyName.ArchiMateElementType]; string eSourceIdentifier = pavcIn.pValues[(int)CecilConst.PropertyName.SourceIdentifier]; string eTargetIdentifier = pavcIn.pValues[(int)CecilConst.PropertyName.TargetIdentifier]; properties ps = ModelFactory.NewProperties(); foreach (CecilConst.PropertyName pn in Enum.GetValues(typeof(CecilConst.PropertyName))) { if (pn == CecilConst.PropertyName.NumberOfItems) { break; } int ipn = (int)pn; if (pavcIn.pValues[ipn] != null) { property p = ModelFactory.NewProperty(ModelFactory.NewValue(pavcIn.pValues[ipn]), pdc[ipn]); ps.property.Add(p); } } ModelConst.RelationshipType eType = (ModelConst.RelationshipType)Enum.Parse(typeof(ModelConst.RelationshipType), type); r = ModelFactory.NewRelationship(fullname, eType, eSourceIdentifier, eTargetIdentifier, ps); r.label.ElementAt(0).label_text = label; // short name for display; fullname to compute unique identifier return(r); }
public void establishRelationship(Object relateMe, relationshipTypes myType) //Create a new relationship { relationship newRelationship = new relationship(); newRelationship.myRelationship = relateMe; newRelationship.type = myType; myRelationships.Add(newRelationship); }
/// <summary> /// Create a record send request make friend from user_one to user_two /// </summary> /// <param name="user_one_id">user_one_id</param> /// <param name="user_two_id">user_two_id</param> /// <returns>return true if send request saved to db, otherwise return false</returns> //public bool SendResquest(int user_one_id, int user_two_id) //{ // //TODO // relationship relationship = new relationship(user_one_id,user_two_id); // try // { // Relationships.Add(relationship); // database.SaveChanges(); // }catch(Exception e) // { // Logging.Log(e.ToString()); // return false; // } // return true; //} //public bool ResponeRequest(int user_one_id, int user_two_id, CONST.FRIEND_OPTIONS user_one_option) //{ // //TODO // var result = from r in Relationships // where r.user_one_id == user_one_id && r.user_two_id == user_two_id // select r; // if(user_one_option == CONST.FRIEND_OPTIONS.Friends) // result.ElementAt(0).status = 1; // else // Relationships.Remove(result.ElementAt(0)); // try // { // database.SaveChanges(); // return true; // } // catch(Exception e){ // Logging.Log(e.ToString()); // return false; // } //} /// <summary> /// Update Relation: Case FRIEND_OPTIONS: None => UnFriend, Cancel Request, Reject Request /// Case FRIEND_OPTIONS: Request => Add Friend /// Case FRIEND_OPTIONS: Confirm => Acept Request /// </summary> /// <param name="user_one_id">User send</param> /// <param name="user_two_id">User receive</param> /// <param name="user_one_option">user's option</param> /// <returns>return true if update successful, otherwise return false</returns> public bool UpdateRelation(int user_one_id, int user_two_id, CONST.FRIEND_OPTIONS user_one_option) { if (user_one_option == CONST.FRIEND_OPTIONS.None) { //UnFriend var result = from r in Relationships where (r.user_one_id == user_one_id && r.user_two_id == user_two_id) || (r.user_one_id == user_two_id && r.user_two_id == user_one_id) select r; if (result.Count() != 1) { return(false); } Relationships.Remove(result.ToList().ElementAt(0)); } else if (user_one_option == CONST.FRIEND_OPTIONS.Request) { //Add Friend relationship relationship; if (user_one_id <= user_two_id) { relationship = new relationship(user_one_id, user_two_id, user_one_id); } else { relationship = new relationship(user_two_id, user_one_id, user_one_id); } Relationships.Add(relationship); } else if (user_one_option == CONST.FRIEND_OPTIONS.Confirm) { //Accept Request var result = from r in Relationships where (r.user_one_id == user_one_id && r.user_two_id == user_two_id && r.status == 0) || (r.user_one_id == user_two_id && r.user_two_id == user_one_id && r.status == 0) select r; if (result.Count() != 1) { return(false); } result.ToList().ElementAt(0).status = 1; } try { if (database.SaveChanges() == 0) { return(false); } return(true); }catch (Exception e) { Logging.Log(e.ToString()); return(false); } }
public company_relationship getOtherRelationship() { company_relationship other = null; try { relationship otherDefault = db.relationship.Where(item => item.id == 20 || item.relationship_en.ToLower() == "other").FirstOrDefault(); if (otherDefault != null) { other = new company_relationship(); other.relationship_en = otherDefault.relationship_en; other.relationship_ar = otherDefault.relationship_ar; other.relationship_es = other.relationship_es; other.relationship_fr = otherDefault.relationship_fr; other.relationship_ru = otherDefault.relationship_ru; } } catch (System.Data.DataException ex) { logger.Error(ex.ToString()); } return(other); }
validateCallback?.Invoke(relationship, nextResourceContext, path);
public static string Relationship(this relationship relationship) { return(relationship.T("relationship")); }
public void UpdateRelationshipMappingGuid(relationship relationship, Guid?newId) { relationship.mappingGuid = newId?.ToString(); relationship.guid = newId?.ToString(); }
public void RemoveRelationshipMapping(relationship relationship) { relationship.mappingGuid = null; }