Ejemplo n.º 1
0
        public JsonResult UpadateStudentProfile(StudentprofileViewModel profileViewModel, string classStatus, ProfileEditor editOperation)
        {
            try
            {
                var register = _context.Register.FirstOrDefault(r => r.AdmnNo.ToUpper().Equals(profileViewModel.AdmnNo.ToUpper()));
                if (editOperation == ProfileEditor.EditContacts)
                {
                    register.Telno       = profileViewModel?.Telno;
                    register.Homeaddress = profileViewModel?.Homeaddress;
                    register.Email       = profileViewModel?.Email;
                }

                if (editOperation == ProfileEditor.EditOthers)
                {
                    register.Language = profileViewModel?.Language;
                    register.Special  = profileViewModel?.Medical;
                    register.Activity = profileViewModel?.Activity;
                }

                if (editOperation == ProfileEditor.EditEmergency)
                {
                    register.Emname    = profileViewModel?.EmergencyName;
                    register.Emrel     = profileViewModel?.EmergencyRelationShip;
                    register.Emtel     = profileViewModel?.EmergencyTelNo;
                    register.Ememail   = profileViewModel?.EmergencyEmail;
                    register.Emaddress = profileViewModel?.EmergencyAddress;
                    register.Emremarks = profileViewModel?.EmergencyRemarks;
                }

                if (editOperation == ProfileEditor.EditDependancies)
                {
                    var dependant = _context.StudDependant.FirstOrDefault(s => s.AdmnNo.ToUpper().Equals(profileViewModel.AdmnNo.ToUpper()));
                    dependant.Names        = profileViewModel?.DependantName;
                    dependant.Relationship = profileViewModel?.DependantRelationShip;
                    dependant.Gender       = profileViewModel?.DependantGender;
                    dependant.Tel          = profileViewModel?.DependantTelNo;
                    dependant.Occupation   = profileViewModel?.DependantOccupation;
                    dependant.Notes        = profileViewModel?.DependantNotes;
                }


                _context.SaveChanges();
                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Profile Updated Successifully"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "An error occurred,please retry : " + ex.Message
                }));
            }
        }
Ejemplo n.º 2
0
        public JsonResult EditStudentProfile(StudentprofileViewModel profileViewModel, ProfileEditor editOperation)
        {
            try
            {
                var token = _tokenValidator.Validate(HttpContext);
                if (!token.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        NotAuthenticated = true,
                        Message = $"Unauthorized:-{token.Message}",
                    }));
                }

                var settings       = _context.PortalConfigs.Any(c => c.Code == "008" && c.Status);
                var profileUpdates = new ProfileUpdates
                {
                    TelNo                = profileViewModel.Telno,
                    Email                = profileViewModel.Email,
                    HomeAddress          = profileViewModel.Homeaddress,
                    UserCode             = profileViewModel.AdmnNo,
                    DateCreated          = DateTime.Now,
                    AllowedAdminApproval = true,
                    Status               = false
                };

                if (settings)
                {
                    var updateProfileResults = _unisolApiProxy.EditStudentProfile(profileViewModel, classStatus, editOperation).Result;
                    var jdata = JsonConvert.DeserializeObject <ReturnData <string> >(updateProfileResults);
                    if (jdata.Success)
                    {
                        var portalUser = _context.Users.FirstOrDefault(u => u.UserName.ToUpper().Equals(profileViewModel.AdmnNo.ToUpper()));
                        if (portalUser != null)
                        {
                            portalUser.Email = profileViewModel.Email;
                            _context.SaveChanges();
                        }

                        return(Json(new ReturnData <string>
                        {
                            Success = true,
                            Message = "Profile Updated successfully"
                        }));
                    }
                }

                _context.ProfileUpdate.Add(profileUpdates);
                _context.SaveChanges();

                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Profile Updated Request received, We shall contact yo shortly"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "An error occured while trying to update the profile, please try again"
                }));
            }
        }
Ejemplo n.º 3
0
        public Task <string> EditStudentProfile(StudentprofileViewModel profileViewModel, string classStatus, ProfileEditor editOperation)
        {
            var response = Post($"profile/upadateStudentProfile/?classStatus={classStatus}&editOperation={editOperation}", profileViewModel);

            return(response);
        }