Exemplo n.º 1
0
        //[HttpPost]
        //public ActionResult AssignUserWithStudent(long StudentId, string ClassName, string SectionName, int Roll)
        //{
        //    vm_GetAllStudentInfo studentVM = new vm_GetAllStudentInfo()
        //    {
        //        StudentId = StudentId,
        //        ClassName = ClassName,
        //        SectionName = SectionName,
        //        Roll = Roll
        //    };
        //    return View("FinalAssignUserWithStudent", studentVM);
        //}


        //public ActionResult FinalAssignUserWithStudent(long StudentId, long UserPhone)
        //{

        //}



        public JsonResult FinalAssignUserWithStudent(string UserPhone, string StudentId)
        {
            ResponseResult responseResult = new ResponseResult();
            AssignGuardianWithStudentVM assignGuardianWithStudentVM = new AssignGuardianWithStudentVM()
            {
                StudentId = Convert.ToInt64(StudentId),
                UserId    = Convert.ToInt64(UserPhone)
            };

            try
            {
                var    res         = _apiRequest.HttpPostRequest(assignGuardianWithStudentVM, "api/User/AssignGuardianWithStudent");
                string apiResponse = res.ToString();
                responseResult = JsonConvert.DeserializeObject <ResponseResult>(apiResponse);

                if (responseResult.MessageCode == "Y")
                {
                    TempData["msgAlert"]        = responseResult.MessageCode;
                    TempData["msgAlertDetails"] = responseResult.SystemMessage;
                }
                else
                {
                    TempData["msgAlert"]        = responseResult.MessageCode;
                    TempData["msgAlertDetails"] = responseResult.SystemMessage;
                }
            }
            catch (Exception ex)
            {
                TempData["msgAlert"]        = "N";
                TempData["msgAlertDetails"] = ex.Message.ToString();
            }
            return(Json(responseResult, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ResponseResult IsStudentGardianRelationExists(AssignGuardianWithStudentVM assignGuardianWithStudentVM)
        {
            ResponseResult responseResult = new ResponseResult();

            try
            {
                var result = _dbContext.RelationStudentGuardians
                             .Where(a => a.StudentId == assignGuardianWithStudentVM.StudentId &&
                                    a.UserId == assignGuardianWithStudentVM.UserId)
                             .SingleOrDefault();

                if (result != null)
                {
                    responseResult.Content       = true;
                    responseResult.MessageCode   = MessageCode.Y.ToString();
                    responseResult.SystemMessage = "Relation Found.";
                }
                else
                {
                    responseResult.Content       = false;
                    responseResult.MessageCode   = MessageCode.N.ToString();
                    responseResult.SystemMessage = "Relation not found.";
                }
            }
            catch (Exception ex)
            {
                responseResult.Content       = null;
                responseResult.MessageCode   = MessageCode.N.ToString();
                responseResult.SystemMessage = ex.Message;
            }
            return(responseResult);
        }
Exemplo n.º 3
0
        public ResponseResult AssignGuardianWithStudent(AssignGuardianWithStudentVM assignGuardianWithStudentVM)
        {
            ResponseResult          responseResult             = new ResponseResult();
            RelationStudentGuardian relationStudentGuardianObj = new RelationStudentGuardian()
            {
                StudentId = assignGuardianWithStudentVM.StudentId,
                UserId    = assignGuardianWithStudentVM.UserId
            };

            try
            {
                if (IsStudentGardianRelationExists1(assignGuardianWithStudentVM) != true)
                {
                    _dbContext.RelationStudentGuardians.Add(relationStudentGuardianObj);
                    _dbContext.SaveChanges();

                    responseResult.Content       = null;
                    responseResult.MessageCode   = MessageCode.Y.ToString();
                    responseResult.SystemMessage = "Data Saved Succesfully.";
                }
                else
                {
                    responseResult.Content       = null;
                    responseResult.MessageCode   = MessageCode.N.ToString();
                    responseResult.SystemMessage = "Relation Already Exists.";
                }
            }
            catch (Exception ex)
            {
                responseResult.Content       = null;
                responseResult.MessageCode   = MessageCode.N.ToString();
                responseResult.SystemMessage = ex.Message;
            }
            return(responseResult);
        }
Exemplo n.º 4
0
        public bool IsStudentGardianRelationExists1(AssignGuardianWithStudentVM assignGuardianWithStudentVM)
        {
            try
            {
                var result = _dbContext.RelationStudentGuardians
                             .Where(a => a.StudentId == assignGuardianWithStudentVM.StudentId &&
                                    a.UserId == assignGuardianWithStudentVM.UserId)
                             .SingleOrDefault();

                if (result != null)
                {
                    return(true);
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }