コード例 #1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            RelationshipMeta relationshipMeta = db.RelationshipMetas.Find(id);

            db.RelationshipMetas.Remove(relationshipMeta);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #2
0
    public static RelationshipMetaViewModel MapDbModelToViewModel(RelationshipMeta dbModel)
    {
        var viewModel = new  RelationshipMetaViewModel();

        viewModel.ID                 = dbModel.ID;
        viewModel.PkAOMMetaID        = dbModel.PkAOMMetaID;
        viewModel.FkAOMMetaID        = dbModel.FkAOMMetaID;
        viewModel.FkAOMFieldMetaID   = dbModel.FkAOMFieldMetaID;
        viewModel.RelationshipTypeID = dbModel.RelationshipTypeID;
        return(viewModel);
    }
コード例 #3
0
        public static RelationshipMetaViewModel MapDbModelToViewModel(RelationshipMeta dbModel)
        {
            var viewModel = new  RelationshipMetaViewModel();

            viewModel.ID               = dbModel.ID;
            viewModel.PkAomMetaId      = dbModel.PkAomMetaId;
            viewModel.FkAomMetaId      = dbModel.FkAomMetaId;
            viewModel.FkAomFieldMetaId = dbModel.FkAomFieldMetaId;
            viewModel.Name             = dbModel.Name;
            viewModel.PkAomFieldMetaId = dbModel.PkAomFieldMetaId;
            return(viewModel);
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,PkAomMetaId,FkAomMetaId,FkAomFieldMetaId,Name,PkAomFieldMetaId")] RelationshipMeta relationshipMeta)
 {
     if (ModelState.IsValid)
     {
         db.Entry(relationshipMeta).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FkAomFieldMetaId = new SelectList(db.AomFieldMetas, "Id", "Name", relationshipMeta.FkAomFieldMetaId);
     ViewBag.FkAomMetaId      = new SelectList(db.AomMetas, "Id", "Name", relationshipMeta.FkAomMetaId);
     ViewBag.PkAomFieldMetaId = new SelectList(db.AomFieldMetas, "Id", "Name", relationshipMeta.PkAomFieldMetaId);
     ViewBag.PkAomMetaId      = new SelectList(db.AomMetas, "Id", "Name", relationshipMeta.PkAomMetaId);
     return(View(relationshipMeta));
 }
コード例 #5
0
        // GET: Admin/RelationshipMetas/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RelationshipMeta relationshipMeta = db.RelationshipMetas.Find(id);

            if (relationshipMeta == null)
            {
                return(HttpNotFound());
            }
            return(View(relationshipMeta));
        }
コード例 #6
0
    public static RelationshipMeta MapInsertModelToDbModel(RelationshipMetaViewModel model, RelationshipMeta newDomainModel = null)
    {
        if (newDomainModel == null)
        {
            newDomainModel = new RelationshipMeta();
        }

        newDomainModel.ID                 = model.ID;
        newDomainModel.PkAOMMetaID        = model.PkAOMMetaID;
        newDomainModel.FkAOMMetaID        = model.FkAOMMetaID;
        newDomainModel.FkAOMFieldMetaID   = model.FkAOMFieldMetaID;
        newDomainModel.RelationshipTypeID = model.RelationshipTypeID;

        return(newDomainModel);
    }
コード例 #7
0
        public ActionResult Create([Bind(Include = "Id,PkAomMetaId,FkAomMetaId,FkAomFieldMetaId,Name,PkAomFieldMetaId")] RelationshipMeta relationshipMeta)
        {
            if (ModelState.IsValid)
            {
                relationshipMeta.Id = Guid.NewGuid();
                db.RelationshipMetas.Add(relationshipMeta);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FkAomFieldMetaId = new SelectList(db.AomFieldMetas, "Id", "Name", relationshipMeta.FkAomFieldMetaId);
            ViewBag.FkAomMetaId      = new SelectList(db.AomMetas, "Id", "Name", relationshipMeta.FkAomMetaId);
            ViewBag.PkAomFieldMetaId = new SelectList(db.AomFieldMetas, "Id", "Name", relationshipMeta.PkAomFieldMetaId);
            ViewBag.PkAomMetaId      = new SelectList(db.AomMetas, "Id", "Name", relationshipMeta.PkAomMetaId);
            return(View(relationshipMeta));
        }
コード例 #8
0
        public async Task <RelationshipMeta> getAssignmentRelationshipMetaByIDAsync(Guid xrefID)
        {
            RelationshipMeta logicRelationshipMeta = await santaContext.ClientRelationXrefs
                                                     .Select(xref => new RelationshipMeta()
            {
                clientRelationXrefID = xref.ClientRelationXrefId,
                relationshipClient   = Mapper.MapClientMeta(xref.RecipientClient),
                eventType            = Mapper.MapEvent(xref.EventType),
                assignmentStatus     = Mapper.MapAssignmentStatus(xref.AssignmentStatus),
                tags      = new List <Logic.Objects.Tag>(),
                removable = xref.ChatMessages.Count > 0
            })
                                                     .FirstOrDefaultAsync(crxr => crxr.clientRelationXrefID == xrefID);

            return(logicRelationshipMeta);
        }
コード例 #9
0
        public static RelationshipMeta MapInsertModelToDbModel(RelationshipMetaViewModel model, RelationshipMeta newDomainModel = null)
        {
            if (newDomainModel == null)
            {
                newDomainModel = new RelationshipMeta();
            }

            newDomainModel.ID               = model.ID;
            newDomainModel.PkAomMetaId      = model.PkAomMetaId;
            newDomainModel.FkAomMetaId      = model.FkAomMetaId;
            newDomainModel.FkAomFieldMetaId = model.FkAomFieldMetaId;
            newDomainModel.Name             = model.Name;
            newDomainModel.PkAomFieldMetaId = model.PkAomFieldMetaId;

            return(newDomainModel);
        }
コード例 #10
0
        /// <summary>
        /// Maps a context relationship to a relationship meta
        /// </summary>
        /// <param name="contextRecipientXref"></param>
        /// <returns></returns>
        public static Logic.Objects.RelationshipMeta MapRelationshipMeta(Data.Entities.ClientRelationXref contextXrefRelationship, Guid clientIDMetaToMap)
        {
            List <ClientTagXref> tagXrefList = contextXrefRelationship.SenderClientId != clientIDMetaToMap?contextXrefRelationship.RecipientClient.ClientTagXref.ToList() : contextXrefRelationship.SenderClient.ClientTagXref.ToList();

            ClientMeta logicMeta = contextXrefRelationship.SenderClientId != clientIDMetaToMap?Mapper.MapClientMeta(contextXrefRelationship.RecipientClient) : Mapper.MapClientMeta(contextXrefRelationship.SenderClient);

            Logic.Objects.RelationshipMeta logicRelationship = new RelationshipMeta()
            {
                relationshipClient   = logicMeta,
                eventType            = Mapper.MapEvent(contextXrefRelationship.EventType),
                clientRelationXrefID = contextXrefRelationship.ClientRelationXrefId,
                tags             = tagXrefList.Select(Mapper.MapTagRelationXref).OrderBy(t => t.tagName).ToList(),
                assignmentStatus = MapAssignmentStatus(contextXrefRelationship.AssignmentStatus),
                removable        = contextXrefRelationship.ChatMessage.Count > 0 ? false : true
            };
            return(logicRelationship);
        }
コード例 #11
0
        // GET: Admin/RelationshipMetas/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RelationshipMeta relationshipMeta = db.RelationshipMetas.Find(id);

            if (relationshipMeta == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FkAomFieldMetaId = new SelectList(db.AomFieldMetas, "Id", "Name", relationshipMeta.FkAomFieldMetaId);
            ViewBag.FkAomMetaId      = new SelectList(db.AomMetas, "Id", "Name", relationshipMeta.FkAomMetaId);
            ViewBag.PkAomFieldMetaId = new SelectList(db.AomFieldMetas, "Id", "Name", relationshipMeta.PkAomFieldMetaId);
            ViewBag.PkAomMetaId      = new SelectList(db.AomMetas, "Id", "Name", relationshipMeta.PkAomMetaId);
            return(View(relationshipMeta));
        }
コード例 #12
0
        public async Task <ActionResult <AssignmentStatus> > UpdateProfileAssignmentStatus(Guid clientID, Guid assignmentXrefID, [FromBody] EditProfileAssignmentStatusModel model)
        {
            // Gets the claims from the URI and check against the client gotten based on auth claims token
            Profile logicProfile = await repository.GetProfileByIDAsync(clientID);

            BaseClient baseCheckerClient = await repository.GetBasicClientInformationByEmail(User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Email).Value);

            List <Guid> assignmentInfo = await repository.getClientAssignmentXrefIDsByIDAsync(baseCheckerClient.clientID);

            // If the checked client is allowed based on token claims, and the checker client has an assignment ID that match the one in the URI (To stop modifying of anyone elses assignments)
            if (logicProfile.clientID == baseCheckerClient.clientID && assignmentInfo.Any(crxr => crxr == assignmentXrefID))
            {
                RelationshipMeta assignment = await repository.getAssignmentRelationshipMetaByIDAsync(assignmentXrefID);

                AssignmentStatus newStatus = await repository.GetAssignmentStatusByID(model.assignmentStatusID);

                try
                {
                    // Update profile and send back the updated recipient
                    await repository.UpdateAssignmentProgressStatusByID(assignmentXrefID, model.assignmentStatusID);

                    await yuleLogger.logModifiedAssignmentStatus(baseCheckerClient, assignment.relationshipClient.clientNickname, assignment.assignmentStatus, newStatus);

                    await repository.SaveAsync();

                    RelationshipMeta newAssignmentMeta = await repository.getAssignmentRelationshipMetaByIDAsync(assignmentXrefID);

                    return(Ok(newAssignmentMeta.assignmentStatus));
                }
                catch (Exception)
                {
                    await yuleLogger.logError(baseCheckerClient, LoggingConstants.MODIFIED_ASSIGNMENT_STATUS_CATEGORY);

                    return(StatusCode(StatusCodes.Status424FailedDependency));
                }
            }
            else
            {
                return(StatusCode(StatusCodes.Status401Unauthorized));
            }
        }
コード例 #13
0
        public async Task logDeletedAssignment(BaseClient requestingClient, BaseClient affectedClient, RelationshipMeta deletedAssignment)
        {
            await repository.CreateNewLogEntry(makeLogTemplateObject(await getCategoryByName(LoggingConstants.DELETED_ASSIGNMENT_CATEGORY), $"{requestingClient.nickname} requested to remove {deletedAssignment.relationshipClient.clientNickname} from {affectedClient.nickname}'s assignment list"));

            await saveLogs();
        }