コード例 #1
0
        public ActionResult <ParentInfoDeleteViewModel> RemoveAssociatedParent(ParentInfoDeleteViewModel parentInfoDeleteViewModel)
        {
            ParentInfoDeleteViewModel parentAssociationshipDelete = new ParentInfoDeleteViewModel();

            try
            {
                if (parentInfoDeleteViewModel.parentInfo.SchoolId > 0)
                {
                    parentAssociationshipDelete = _parentInfoRegisterService.RemoveAssociatedParent(parentInfoDeleteViewModel);
                }
                else
                {
                    parentAssociationshipDelete._token      = parentInfoDeleteViewModel._token;
                    parentAssociationshipDelete._tenantName = parentInfoDeleteViewModel._tenantName;
                    parentAssociationshipDelete._failure    = true;
                    parentAssociationshipDelete._message    = "Please enter valid school id";
                }
            }
            catch (Exception es)
            {
                parentAssociationshipDelete._failure = true;
                parentAssociationshipDelete._message = es.Message;
            }
            return(parentAssociationshipDelete);
        }
コード例 #2
0
        /// <summary>
        /// Remove Associated Parent
        /// </summary>
        /// <param name="parentInfoDeleteViewModel"></param>
        /// <returns></returns>
        public ParentInfoDeleteViewModel RemoveAssociatedParent(ParentInfoDeleteViewModel parentInfoDeleteViewModel)
        {
            try
            {
                string AssociateParentAfterDel;
                var    AssociationshipDataToDel = parentInfoDeleteViewModel.parentInfo.TenantId + "#" + parentInfoDeleteViewModel.parentInfo.SchoolId + "#" + parentInfoDeleteViewModel.StudentId;

                var ParentInfo = this.context?.ParentInfo.FirstOrDefault(x => x.TenantId == parentInfoDeleteViewModel.parentInfo.TenantId && x.SchoolId == parentInfoDeleteViewModel.parentInfo.SchoolId && x.ParentId == parentInfoDeleteViewModel.parentInfo.ParentId);

                if (ParentInfo != null)
                {
                    var      AssociationshipData         = ParentInfo.Associationship;
                    string[] studentAssociateWithParents = AssociationshipData.Split(" | ", StringSplitOptions.RemoveEmptyEntries);
                    studentAssociateWithParents = studentAssociateWithParents.Where(w => w != AssociationshipDataToDel).ToArray();
                    if (studentAssociateWithParents.Count() > 1)
                    {
                        AssociateParentAfterDel = string.Join(" | ", studentAssociateWithParents);
                    }
                    else if (studentAssociateWithParents.Count() == 1)
                    {
                        AssociateParentAfterDel = string.Concat(studentAssociateWithParents);
                    }
                    else
                    {
                        AssociateParentAfterDel = null;
                    }
                    ParentInfo.Associationship = AssociateParentAfterDel;
                    this.context?.SaveChanges();
                    parentInfoDeleteViewModel._message = "Associationship Remove Successfully";
                }
            }
            catch (Exception es)
            {
                parentInfoDeleteViewModel._failure = true;
                parentInfoDeleteViewModel._message = es.Message;
            }
            return(parentInfoDeleteViewModel);
        }
コード例 #3
0
        /// <summary>
        /// Remove Associated Parent
        /// </summary>
        /// <param name="parentInfoDeleteViewModel"></param>
        /// <returns></returns>
        public ParentInfoDeleteViewModel RemoveAssociatedParent(ParentInfoDeleteViewModel parentInfoDeleteViewModel)
        {
            ParentInfoDeleteViewModel parentAssociationshipDelete = new ParentInfoDeleteViewModel();

            try
            {
                if (TokenManager.CheckToken(parentInfoDeleteViewModel._tenantName + parentInfoDeleteViewModel._userName, parentInfoDeleteViewModel._token))
                {
                    parentAssociationshipDelete = this.parentInfoRepository.RemoveAssociatedParent(parentInfoDeleteViewModel);
                }
                else
                {
                    parentAssociationshipDelete._failure = true;
                    parentAssociationshipDelete._message = TOKENINVALID;
                }
            }
            catch (Exception es)
            {
                parentAssociationshipDelete._failure = true;
                parentAssociationshipDelete._message = es.Message;
            }

            return(parentAssociationshipDelete);
        }