public async Task <ActionResult> UpdateProfile([Bind] Profile profile, string clientKey = null, string secretKey = null)
        {
            Profile model = new Profile();

            ViewBag.IsAlertResponse        = false;
            ViewBag.ActivityResponsMessage = null;

            var identity = (ClaimsPrincipal)Thread.CurrentPrincipal;
            var userName = identity.Claims.Where(c => c.Type == ClaimTypes.Name)
                           .Select(c => c.Value).SingleOrDefault();
            //side menu validasi
            var fetchingProfileList = await reader.SearchProfileIndex(userName);

            var role = fetchingProfileList.Data.FirstOrDefault(x => x.RoleID == x.RoleID)?.RoleID;

            ViewBag.roleID = role;


            var         DateRequest = profile.DOB;
            var         time        = DateTime.Now.ToString("hh:mm:ss");
            string      format      = "MM/dd/yyyy";
            CultureInfo provider    = CultureInfo.InvariantCulture;
            var         date        = DateTime.ParseExact(DateRequest, format, provider);

            var dateFinal = Convert.ToDateTime(date).ToString("yyyy-MM-ddThh:mm:ss.549Z").Substring(0, 10) + "T" + time + ".549Z";
            var item      = new Profile();

            if (role == "4")
            {
                item = new Profile()
                {
                    //CallItemDate = Convert.ToDateTime(date).ToString("yyyy-MM-ddThh:mm:ss.549Z"),
                    Email          = profile.Email,
                    FullName       = profile.FullName,
                    ProfileID      = profile.ProfileID,
                    RoleID         = "0",
                    CreateDate     = dateFinal,
                    Username       = userName,
                    Profession     = profile.Profession,
                    DOB            = dateFinal,
                    Gender         = profile.Gender,
                    Phone          = profile.Phone,
                    CoverImage     = profile.CoverImage,
                    ProfileImage   = profile.ProfileImage,
                    Experience     = profile.Experience,
                    Jabatan        = profile.Jabatan,
                    Qualification  = profile.Qualification,
                    Type           = profile.Type,
                    SalaryRange    = profile.SalaryRange,
                    Setyourprofile = profile.Setyourprofile,
                    AboutSelf      = profile.AboutSelf,
                    JobTitle       = profile.JobTitle,
                    SectorID       = profile.SectorID,
                    AddID          = profile.AddID,
                    PostalCode     = profile.PostalCode,
                    FullAddress    = profile.FullAddress,
                    CompanyName    = "-",
                    IsActive       = profile.IsActive,
                };
            }
            else if (role == "5")
            {
                item = new Profile()
                {
                    //CallItemDate = Convert.ToDateTime(date).ToString("yyyy-MM-ddThh:mm:ss.549Z"),
                    Email          = profile.Email,
                    FullName       = profile.FullName,
                    ProfileID      = profile.ProfileID,
                    RoleID         = "0",
                    CreateDate     = dateFinal,
                    Username       = userName,
                    Profession     = "-",
                    DOB            = dateFinal,
                    Gender         = "-",
                    Phone          = profile.Phone,
                    CoverImage     = profile.CoverImage,
                    ProfileImage   = profile.ProfileImage,
                    Experience     = "-",
                    Jabatan        = "-",
                    Qualification  = "-",
                    Type           = "-",
                    SalaryRange    = "-",
                    Setyourprofile = profile.Setyourprofile,
                    AboutSelf      = profile.AboutSelf,
                    JobTitle       = "-",
                    SectorID       = profile.SectorID,
                    AddID          = profile.AddID,
                    PostalCode     = profile.PostalCode,
                    FullAddress    = profile.FullAddress,
                    CompanyName    = profile.CompanyName,
                    IsActive       = profile.IsActive,
                };
            }
            else
            {
                item = new Profile()
                {
                    Email          = profile.Email,
                    FullName       = profile.FullName,
                    ProfileID      = profile.ProfileID,
                    RoleID         = "0",
                    CreateDate     = dateFinal,
                    Username       = userName,
                    Profession     = profile.Profession,
                    DOB            = dateFinal,
                    Gender         = profile.Gender,
                    Phone          = profile.Phone,
                    CoverImage     = profile.CoverImage,
                    ProfileImage   = profile.ProfileImage,
                    Experience     = profile.Experience,
                    Jabatan        = profile.Jabatan,
                    Qualification  = profile.Qualification,
                    Type           = profile.Type,
                    SalaryRange    = profile.SalaryRange,
                    Setyourprofile = profile.Setyourprofile,
                    AboutSelf      = profile.AboutSelf,
                    JobTitle       = profile.JobTitle,
                    SectorID       = profile.SectorID,
                    AddID          = profile.AddID,
                    PostalCode     = profile.PostalCode,
                    FullAddress    = profile.FullAddress,
                    CompanyName    = profile.CompanyName,
                    IsActive       = profile.IsActive,
                };
            }

            var result = await writer.UpdateProfile(item, clientKey, secretKey);

            if (result.Item2)
            {
                ViewBag.IsAlertResponse = true;

                var responser = new ActivityResponsMessage()
                {
                    Message      = "The data has been updated successfully!",
                    RequestTime  = DateTime.Now,
                    ResponseTime = DateTime.Now,
                    Type         = "success"
                };

                ViewBag.ActivityResponsMessage = responser;
            }
            else
            {
                ViewBag.IsAlertResponse = true;

                var responser = new ActivityResponsMessage()
                {
                    Message      = "Opss.. Failed to update item!",
                    RequestTime  = DateTime.Now,
                    ResponseTime = DateTime.Now,
                    Type         = "error"
                };

                ViewBag.ActivityResponsMessage = responser;
            }


            //balikin data get atau panggil method get



            //Get dropdown list gender
            string genderString = "Laki-laki,Wanita";
            IEnumerable <GenderProfile> Infogender =
                from name in genderString.Split(',')
                select new GenderProfile()
            {
                Gender     = name,
                NameGender = name
            };
            List <GenderProfile> listGender = Infogender.ToList();

            ViewBag.GenderList = listGender;

            //Get dropdown list Experience
            string experienceString = "Fresh Graduate,1 Tahun,2 Tahun,3 Tahun,4 Tahun,5 Tahun";
            IEnumerable <ExperienceProfile> Infoexperience =
                from name in experienceString.Split(',')
                select new ExperienceProfile()
            {
                Experience     = name,
                NameExperience = name
            };
            List <ExperienceProfile> listExp = Infoexperience.ToList();

            ViewBag.ExpList = listExp;


            //Get dropdown list Qualification
            string QualificationString = "SMK/SMA,Diploma 1,Diploma 2,Diploma 3,Sarjana 1,Sarjana 2,Sarjana 3";
            IEnumerable <QualificationProfile> InfoQualification =
                from name in QualificationString.Split(',')
                select new QualificationProfile()
            {
                Qualification     = name,
                NameQualification = name
            };
            List <QualificationProfile> listQualification = InfoQualification.ToList();

            ViewBag.QualificationList = listQualification;


            //Get dropdown list Jabatan
            string JabatanString = "Staff,Manager,Supervisor";
            IEnumerable <JabatanProfile> InfoJabatan =
                from name in JabatanString.Split(',')
                select new JabatanProfile()
            {
                Jabatan     = name,
                NameJabatan = name
            };
            List <JabatanProfile> listJabatan = InfoJabatan.ToList();

            ViewBag.JabatanList = listJabatan;

            //Get dropdown list Type
            string TypeString = "Freelance,Kontrak,Paruh Waktu,Penuh Waktu";
            IEnumerable <TypeProfile> InfoType =
                from name in TypeString.Split(',')
                select new TypeProfile()
            {
                Type     = name,
                NameType = name
            };
            List <TypeProfile> listType = InfoType.ToList();

            ViewBag.TypeList = listType;

            //Get dropdown list Setyourprofile
            string SetyourprofileString = "Public,Private";
            IEnumerable <SetYourProfile> InfoSetyourprofile =
                from name in SetyourprofileString.Split(',')
                select new SetYourProfile()
            {
                Setyourprofile     = name,
                NameSetYourProfile = name
            };
            List <SetYourProfile> listSetyourprofile = InfoSetyourprofile.ToList();

            ViewBag.SetyourprofileList = listSetyourprofile;

            //Get dropdown list Profession
            string ProfessionString = "Professional,Private";
            IEnumerable <ProfessionProfile> InfoProfession =
                from name in ProfessionString.Split(',')
                select new ProfessionProfile()
            {
                Profession     = name,
                NameProfession = name
            };
            List <ProfessionProfile> listProfession = InfoProfession.ToList();

            ViewBag.ProfessionList = listProfession;


            var itemAdd = new SearchAddress()
            {
                City     = null,
                Country  = null,
                Provinsi = null
            };


            var AddressResult = await reader.SearchAddress(itemAdd);

            ViewBag.AddressList = AddressResult;

            var itemSector = new SearchSector()
            {
                SectorName = null
            };

            var SectorResult = await reader.SearchSector(itemSector);

            ViewBag.SectorList = SectorResult;

            //setting label kanan
            var FullNameRightLabel = fetchingProfileList.Data.FirstOrDefault(x => x.FullName == x.FullName)?.FullName;

            ViewBag.FullNameLabel = FullNameRightLabel;

            var ProfessionRightLabel = fetchingProfileList.Data.FirstOrDefault(x => x.Profession == x.Profession)?.Profession;

            ViewBag.ProfessionLabel = ProfessionRightLabel;

            var EmailRightLabel = fetchingProfileList.Data.FirstOrDefault(x => x.Email == x.Email)?.Email;

            ViewBag.EmailLabel = EmailRightLabel;

            var PhoneRightLabel = fetchingProfileList.Data.FirstOrDefault(x => x.Phone == x.Phone)?.Phone;

            ViewBag.PhoneLabel = PhoneRightLabel;

            var JobTitleRightLabel = fetchingProfileList.Data.FirstOrDefault(x => x.JobTitle == x.JobTitle)?.JobTitle;

            ViewBag.JobTitleLabel = JobTitleRightLabel;


            //formatRight tanggal kanan
            var DOBRightLabel = fetchingProfileList.Data.FirstOrDefault(x => x.DOB == x.DOB)?.DOB;
            var DOBRightTemp  = DOBRightLabel.Substring(0, 10);
            //var time = DateTime.Now.ToString("hh:mm:ss");
            string      formatRight   = "yyyy-MM-dd";
            CultureInfo providerRight = CultureInfo.InvariantCulture;
            var         dateRight     = DateTime.ParseExact(DOBRightTemp, formatRight, providerRight);

            var dateFinalRight = Convert.ToDateTime(dateRight).ToString("dd MMMM yyyy");

            ViewBag.DOBLabel = dateFinalRight;


            //await Task.Run(() =>
            //{
            //    ViewBag.MemberList = reader.GetMemberAsync().Result;
            //});

            return(await Task.FromResult(View(profile)));
        }
Пример #2
0
    private void AuthStatusCallBack(int status)
    {
        ViewBag.IsAlertResponse        = false;
        ViewBag.ActivityResponsMessage = null;

        if (status == AuthStatus.Status(AuthStatusType.Registered))
        {
            ViewBag.IsAlertResponse = true;

            var responser = new ActivityResponsMessage()
            {
                Message      = "Congratulation, you have been registered!",
                RequestTime  = DateTime.Now,
                ResponseTime = DateTime.Now,
                Type         = "success"
            };

            ViewBag.ActivityResponsMessage = responser;
        }
        else if (status == AuthStatus.Status(AuthStatusType.Unregistered))
        {
            ViewBag.IsAlertResponse = true;

            var responser = new ActivityResponsMessage()
            {
                Message      = "Please try again, you have not been registered!",
                RequestTime  = DateTime.Now,
                ResponseTime = DateTime.Now,
                Type         = "error"
            };

            ViewBag.ActivityResponsMessage = responser;
        }
        else if (status == AuthStatus.Status(AuthStatusType.Active))
        {
            ViewBag.IsAlertResponse = true;

            var responser = new ActivityResponsMessage()
            {
                Message      = "Congratulation, your account has been activated!",
                RequestTime  = DateTime.Now,
                ResponseTime = DateTime.Now,
                Type         = "success"
            };

            ViewBag.ActivityResponsMessage = responser;
        }
        else if (status == AuthStatus.Status(AuthStatusType.NotActive))
        {
            ViewBag.IsAlertResponse = true;

            var responser = new ActivityResponsMessage()
            {
                Message      = "Please try again, your account has not been activated!",
                RequestTime  = DateTime.Now,
                ResponseTime = DateTime.Now,
                Type         = "error"
            };

            ViewBag.ActivityResponsMessage = responser;
        }
        else if (status == AuthStatus.Status(AuthStatusType.LoginSuccess))
        {
            ViewBag.IsAlertResponse = true;

            var responser = new ActivityResponsMessage()
            {
                Message      = "Congratulation, login successfull!",
                RequestTime  = DateTime.Now,
                ResponseTime = DateTime.Now,
                Type         = "success"
            };

            ViewBag.ActivityResponsMessage = responser;
        }
        else if (status == AuthStatus.Status(AuthStatusType.LoginFailed))
        {
            ViewBag.IsAlertResponse = true;

            var responser = new ActivityResponsMessage()
            {
                Message      = "Please try again, your username & password is wrong!",
                RequestTime  = DateTime.Now,
                ResponseTime = DateTime.Now,
                Type         = "error"
            };

            ViewBag.ActivityResponsMessage = responser;
        }
        else
        {
            ViewBag.IsAlertResponse = true;

            var responser = new ActivityResponsMessage()
            {
                Message      = "It's looks like you are not logged in",
                RequestTime  = DateTime.Now,
                ResponseTime = DateTime.Now,
                Type         = "error"
            };

            ViewBag.ActivityResponsMessage = responser;
        }
    }