protected async void TakePhoto(object sender, EventArgs args)
        {
            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await Application.Current.MainPage.DisplayAlert("No Camera", ":( No camera available.", "OK");

                return;
            }
            var photo = await Plugin.Media.CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions()
            {
                AllowCropping = true,
                PhotoSize     = PhotoSize.Medium
            });

            if (BindingContext == null)
            {
                BindingContext = viewModel = new CreateProfileViewModel();
            }

            if (photo != null)
            {
                viewModel.Avatar = photo;
                Avatar.Source    = ImageSource.FromStream(() =>
                {
                    var stream = photo.GetStream();
                    return(stream);
                });
            }
        }
        public IActionResult Create()
        {
            var model = new CreateProfileViewModel
            {
                Entities = _contextEntities.Table.AsEnumerable().Where(x => x.EntityType == "Profile")
            };

            return(View(model));
        }
Example #3
0
        public IActionResult CreateProfile()
        {
            var model = new CreateProfileViewModel();

            model.Education         = new EducationViewModel();
            model.SelectPost        = new SelectPostViewModel();
            model.SelectPost.Posts  = this._positionService.GetAllPosition();
            model.SelectPost.PostId = model.SelectPost.Posts.FirstOrDefault().Id;
            return(View(model));
        }
Example #4
0
        public ActionResult Create(CreateProfileViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.Counties = GetAllCounties().ToList();

                if (model.CityId != null)
                {
                    model.CityId = null;
                }

                return(View(model));
            }

            var newProfile = new Profile()
            {
                Id               = model.Id,
                FirstName        = model.FirstName,
                LastName         = model.LastName,
                IsMale           = model.IsMale,
                IsPublic         = model.IsPublic,
                Birthday         = model.Birthday,
                IsDeletedByAdmin = false,
                CountyId         = model.CountyId,
                CityId           = model.CityId
            };

            db.Profiles.Add(newProfile);
            db.SaveChanges();

            if (model.ProfilePhoto != null)
            {
                MemoryStream target = new MemoryStream();
                model.ProfilePhoto.InputStream.CopyTo(target);
                byte[] data = target.ToArray();

                var newPhotoToAdd = new Photo()
                {
                    Content   = data,
                    ProfileId = model.Id
                };

                db.Photos.Add(newPhotoToAdd);
                db.SaveChanges();

                if (TryUpdateModel(newProfile))
                {
                    newProfile.ProfilePhotoId = newPhotoToAdd.Id;
                    db.SaveChanges();
                }
            }

            return(RedirectToAction("Show", "Profile", new { userId = newProfile.Id }));
        }
Example #5
0
        public ActionResult Create(CreateProfileViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var dbo = this.Mapper.Map <UserProfile>(model);
                dbo.IsActive = true;
                dbo.UserId   = this.User.Identity.GetUserId();
                this.profiles.AddBasicProfile(dbo);
            }

            return(this.Redirect("/"));
        }
Example #6
0
        public ActionResult Create(CreateProfileViewModel model)
        {
            if (this.ModelState.IsValid)
            {
                var dbo = this.Mapper.Map<UserProfile>(model);
                dbo.IsActive = true;
                dbo.UserId = this.User.Identity.GetUserId();
                this.profiles.AddBasicProfile(dbo);
            }

            return this.Redirect("/");
        }
Example #7
0
        public ActionResult Create()
        {
            var currentUserId = User.Identity.GetUserId();

            var model = new CreateProfileViewModel
            {
                Id       = currentUserId,
                Counties = GetAllCounties().ToList()
            };

            return(View(model));
        }
Example #8
0
        //
        // GET: /Profile/Create/
        public ActionResult Create()
        {
            var model = new CreateProfileViewModel();

            model.Subjects     = GetSubjectsSelectedList();
            model.Cities       = GetCitiesSelectedList();
            model.Time         = GetLessonTimeSelectedList();
            model.Institutions = GetInstitutionsGroupDropList();

            var id = User.Identity.GetUserId();

            model.User = Db.Users.FirstOrDefault(x => x.Id == id);

            return(View(model));
        }
Example #9
0
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            StateHelper helper = new StateHelper(State);

            if (Country == null)
            {
                Country = helper.GetValue <Country>("Country", null);
            }
            if (viewModel == null)
            {
                viewModel = helper.GetValue("ViewModel", new CreateProfileViewModel());
            }
            viewModel.Country = Country;
            DataContext       = viewModel;

            //this.RestoreState();
        }
Example #10
0
        public CreateProfileResponseViewModel CreateProfile(CreateProfileViewModel createProfileViewModel)
        {
            var newProfile = new Profile
            {
                IdentityId = createProfileViewModel.IdentityId,
                Name       = createProfileViewModel.Name,
                SystemName = createProfileViewModel.SystemName
            };

            _profileService.InsertProfile(newProfile);



            return(new CreateProfileResponseViewModel
            {
                Profile = (_profileService.GetProfileById(newProfile.Id))
            });
        }
        public IActionResult Create(CreateProfileViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            try
            {
                _context.Profiles.Add(model.Adapt <Profile>());
                _context.SaveChanges();
                return(RedirectToAction(nameof(Index), "Profile"));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("fail", e.Message);
            }

            return(View(model));
        }
Example #12
0
        public async Task <ActionResult> Create([Bind(Include = "FirstName,LastName,Email,Password,RoleNumber,DateOfBirth")] CreateProfileViewModel profileViewModel)
        {
            if (ModelState.IsValid)
            {
                var profilToAdd = new ProfileModel()
                {
                    Email       = profileViewModel.Email,
                    Role        = (Role)profileViewModel.RoleNumber,
                    FirstName   = profileViewModel.FirstName,
                    LastName    = profileViewModel.LastName,
                    Password    = profileViewModel.Password,
                    DateOfBirth = profileViewModel.DateOfBirth
                };

                await _profileService.CreateAsync(profilToAdd);

                return(RedirectToAction("Index"));
            }

            return(View(profileViewModel));
        }
        public ActionResult Create(CreateProfileViewModel requestedViewModel)
        {
            if (ModelState.IsValid)
            {
                if (ProfileService.UserNameInUse(requestedViewModel.CreateProfileForm.Username))
                {
                    ModelState.AddModelError("CreateProfileForm.Username", "Brugernavnet er i brug");
                }

                if (ModelState.IsValid)
                {
                    var profile = ProfileService.Create(requestedViewModel.CreateProfileForm.Username, requestedViewModel.CreateProfileForm.Password, requestedViewModel.CreateProfileForm.Description, requestedViewModel.CreateProfileForm.Picture);
                }
            }

            return(View("Create", new CreateProfileViewModel()
            {
                MenuKey = "profile",
                LoginForm = new LoginFormViewModel(),
                CreateProfileForm = new CreateProfileFormViewModel()
            }));
        }
Example #14
0
 public ActionResult Create(CreateProfileViewModel model)
 {
     try
     {
         string FileName = UploadFile(model.File) ?? string.Empty;
         if (ModelState.IsValid)
         {
             var profile = new Profile
             {
                 AboutUs     = model.AboutUs,
                 Image       = FileName,
                 Address1    = model.Address1,
                 Address2    = model.Address2,
                 Address3    = model.Address3,
                 Email       = model.Email,
                 Phone       = model.Phone,
                 Mission     = model.Mission,
                 Vission     = model.Vission,
                 Care        = model.Care,
                 Plan        = model.Plan,
                 ClientNum   = model.ClientNum,
                 WorkerNum   = model.WorkerNum,
                 ProjectsNum = model.ProjectsNum,
                 HoursNum    = model.HoursNum
             };
             repository.Add(profile);
             return(RedirectToAction("index"));
         }
         ModelState.AddModelError("", "Please review the input fields");
         return(View(model));
     }
     catch
     {
         return(View());
     }
 }
 public CreateProfileView()
 {
     this.InitializeComponent();
     DataContext = new CreateProfileViewModel();
 }
 public CreateProfileResponseViewModel CreateProfile(CreateProfileViewModel createProfileViewModel)
 {
     return(_createProfileService.CreateProfile(createProfileViewModel));
 }
 public IActionResult CreateEducationFromProfileCreate(CreateProfileViewModel model)
 {
     return(View());
 }
Example #18
0
        public async System.Threading.Tasks.Task <IActionResult> CreateProfile(CreateProfileViewModel model)
        {
            if (!ModelState.IsValid)
            {
                model.SelectPost.Posts  = this._positionService.GetAllPosition();
                model.SelectPost.PostId = model.SelectPost.Posts.FirstOrDefault().Id;
                return(View(model));
            }

            var person = new Person
            {
                LastName   = model.LastName,
                FirstName  = model.FirstName,
                MiddleName = model.MiddleName,
                Gender     = (DAL.Gender)model.Gender,
                INN        = model.INN,
                SNILS      = model.SNILS,
                Post       = new Position
                {
                    Id = model.SelectPost.PostId
                }
            };

            var education = new Education();

            var files = HttpContext.Request.Form.Files;

            if (files.Count > 0)
            {
                var allowedExtensions = new[] { ".png", ".jpg" };
                foreach (var file in files)
                {
                    if (file.Name == "profileImage")
                    {
                        using (var memoryStream = new MemoryStream())
                        {
                            await file.CopyToAsync(memoryStream);

                            string fileExtension = Path.GetExtension(file.FileName);
                            if (!allowedExtensions.Contains(fileExtension))
                            {
                                return(View(model));
                            }
                            person.Image = memoryStream.ToArray();
                        }
                    }
                    else if (file.Name == "educationImage")
                    {
                        using (var memoryStream = new MemoryStream())
                        {
                            await file.CopyToAsync(memoryStream);

                            string fileExtension = Path.GetExtension(file.FileName);
                            if (!allowedExtensions.Contains(fileExtension))
                            {
                                return(View(model));
                            }
                            education.File = memoryStream.ToArray();
                        }
                    }
                }
            }
            var resultPerson = this._personService.CreatePerson(person);

            var personPosition = new PersonPosition
            {
                PersonId   = resultPerson.Id,
                PositionId = model.SelectPost.PostId
            };

            this._personPositionService.AddPersonPosition(personPosition);

            if (education.File != null)
            {
                education.EndDate  = model.Education.EndDate;
                education.PersonId = resultPerson.Id;
                this._educationService.CreateEducation(education);
            }

            var passport = new Passport
            {
                PersonId   = resultPerson.Id,
                Series     = model.PassportSeries,
                Number     = model.PassportNumber,
                GivenBy    = model.PassportGivenBy,
                Address    = model.PassportAddress,
                DateOfGive = model.PassportDateOfGive
            };

            this._passportService.CreatePassport(passport);

            var insurance = new InsurancePolicy
            {
                PersonId = resultPerson.Id,
                Number   = model.InsuranceNumber,
                Company  = model.InsuranceCompany
            };

            this._insuranceService.CreatePolicy(insurance);

            return(RedirectToAction("Persons", "Person"));
        }
 public CreateProfile(CreateProfileViewModel ViewModel) : this()
 {
     this.viewModel = ViewModel;
     BindingContext = this.viewModel;
 }
Example #20
0
        public ActionResult Create(CreateProfileViewModel model)
        {
            if (ModelState.IsValid)
            {
                Teacher t = new Teacher();
                t.Age         = model.Age.Value;
                t.City        = model.City;
                t.Street      = model.Street;
                t.HomeNum     = model.HomeNum.Value;
                t.LessonPrice = model.LessonPrice.Value;
                t.LessonTime  = int.Parse(model.LessonTime);
                t.Education   = model.Education;
                t.Institution = model.Institution;
                t.About       = model.About;
                t.Phone       = model.Phone;
                t.PictureUrl  = model.PictureUrl;
                t.isActive    = model.isActive;
                // take care of subjects
                foreach (var idx in model.SubjectsId)
                {
                    int            i    = int.Parse(idx);
                    var            subj = Db.Subjects.FirstOrDefault(x => x.Id == i);
                    SubjectToTeach stt  = new SubjectToTeach();
                    stt.SubjectId = int.Parse(idx);
                    stt.Name      = subj.Name;
                    t.SubjectsToTeach.Add(stt);
                }

                // get user geolocation by address
                t.GeoLocation = new GeoLocation(t.GetAddressForMap());
                // set relation to user
                if (User.Identity.IsAuthenticated)
                {
                    t.ApplicationUserId = User.Identity.GetUserId();
                }

                // add teacher to collection
                Db.Teachers.Add(t);
                // save changes to db
                Db.SaveChanges();

                return(RedirectToAction("Index", "Profile"));
            }
            else
            {
                // ovverride not number message
                if (ModelState["HomeNum"].Errors.Count > 0 &&
                    ModelState["HomeNum"].Errors.FirstOrDefault().ErrorMessage.Contains("is not valid"))
                {
                    ModelState["HomeNum"].Errors.Clear();
                    ModelState.AddModelError("HomeNum", "* רק מספרים");
                }
            }
            // model not valid get data again and return to page
            model.Subjects     = GetSubjectsSelectedList();
            model.Cities       = GetCitiesSelectedList();
            model.Time         = GetLessonTimeSelectedList();
            model.Institutions = GetInstitutionsGroupDropList();

            var id = User.Identity.GetUserId();

            model.User = Db.Users.FirstOrDefault(x => x.Id == id);

            return(View(model));
        }
        private CreateProfileViewModel GetCreateProfileViewModel(Profile profile)
        {
            var workgroupList = _repository.Workgroups.Where(w => w.IsAssignable).Select(w => new SelectListItem
            {
                Text     = w.DisplayName,
                Value    = w.WorkgroupId.ToString(),
                Selected = w.WorkgroupId == profile.Workgroup.WorkgroupId
            }).ToList();
            var templateList = _repository.Templates.Select(t => new SelectListItem
            {
                Text     = t.Title,
                Value    = t.TemplateId.ToString(),
                Selected = t.TemplateId == profile.Template.TemplateId
            }).ToList();
            var widgetList = !_repository.Widgets.Any() ? new List <SelectListItem>() : _repository.Widgets.Select(w => new SelectListItem
            {
                Text  = w.Name,
                Value = w.WidgetId.ToString()
                        //Selected = profile.Widget != null && w.WidgetId == profile.Widget.WidgetId
            }).ToList();

            widgetList.Add(new SelectListItem
            {
                Text  = "None",
                Value = "-1"
                        //Selected = profile.Widget == null
            });

            var skillsList = !_repository.Skills.Any(s => s.IsAssignable) ? new List <Skill>() : _repository.Skills.Where(s => s.IsAssignable).ToList();
            var skills     = new List <int>();

            if (profile.Skills != null && profile.Skills.Any())
            {
                skills = profile.Skills.Select(s => s.SkillId).ToList();
            }
            var scheduleList = !_repository.Schedules.Any(s => s.IsAssignable) ? new List <Schedule>() : _repository.Schedules.Where(s => s.IsAssignable).ToList();
            var schedules    = new List <int>();

            if (profile.Schedules != null && profile.Schedules.Any())
            {
                schedules = profile.Schedules.Select(s => s.Id).ToList();
            }
            var model = new CreateProfileViewModel
            {
                ProfileId      = profile.ProfileId,
                ProfileName    = profile.Name,
                Description    = profile.Description,
                HeaderLogoPath = profile.HeaderLogoPath,
                HeaderText     = profile.HeaderText,
                Logos          = GetLogos(),
                Workgroup      = profile.Workgroup.WorkgroupId,
                Widget         = profile.Widget != null ? profile.Widget.WidgetId : -1,
                Template       = profile.Template.TemplateId,
                Skills         = skills,
                WorkgroupList  = workgroupList,
                TemplateList   = templateList,
                WidgetList     = widgetList,
                SkillsList     = skillsList,
                IncludeUserDataAsAttributes = profile.IncludeUserDataAsAttributes,
                IncludeUserDataAsCustomInfo = profile.IncludeUserDataAsCustomInfo,
                GeneratedScript             = GenerateJavascriptForProfile(profile.Name),
                Schedules        = schedules,
                SchedulesList    = scheduleList,
                AllowAttachments = profile.AllowAttachments
            };

            return(model);
        }
Example #22
0
        // GET: Admin/Create
        public ActionResult Create()
        {
            var createProfilViewModel = new CreateProfileViewModel();

            return(View(createProfilViewModel));
        }
        public ActionResult UpdateProfile(CreateProfileViewModel model)
        {
            try
            {
                var existingName = _repository.Profiles.FirstOrDefault(p => p.Name.ToLower() == model.ProfileName.ToLower() && p.ProfileId != model.ProfileId);
                var widget       = _repository.Widgets.FirstOrDefault(w => w.WidgetId == model.Widget);
                var template     = _repository.Templates.FirstOrDefault(t => t.TemplateId == model.Template);
                var workgroup    = _repository.Workgroups.FirstOrDefault(w => w.WorkgroupId == model.Workgroup);
                var user         = _repository.Users.Find(User.Identity.GetUserId());
                var skills       = model.Skills != null && model.Skills.Any() ? model.Skills.Select(skillId => _repository.Skills.Find(skillId)).ToList() : null;
                var schedules    = model.Schedules != null && model.Schedules.Any() ? model.Schedules.Select(i => _repository.Schedules.Find(i)).ToList() : null;

                if (existingName != null)
                {
                    ModelState.AddModelError("", "Profile Name is not Unique.");
                }
                ////Need to add this back
                //if (widget == null)
                //{
                //    ModelState.AddModelError("","Widget Not Found.");
                //}
                if (template == null)
                {
                    ModelState.AddModelError("", "Template Not Found.");
                }
                if (workgroup == null)
                {
                    ModelState.AddModelError("", "Workgroup Not Found.");
                }
                if (ModelState.IsValid)
                {
                    var profile = _repository.Profiles.Find(model.ProfileId);
                    if (profile != null)
                    {
                        profile.Name           = model.ProfileName;
                        profile.HeaderLogoPath = model.HeaderLogoPath;
                        profile.HeaderText     = model.HeaderText;
                        profile.Description    = model.Description;
                        profile.Template       = template;
                        profile.Widget         = widget;
                        profile.Workgroup      = workgroup;
                        profile.Skills.Clear();
                        profile.Skills        = skills;
                        profile.LastUpdatedBy = user;
                        profile.LastUpdatedOn = DateTime.Now;
                        profile.IncludeUserDataAsAttributes = model.IncludeUserDataAsAttributes;
                        profile.IncludeUserDataAsCustomInfo = model.IncludeUserDataAsCustomInfo;
                        profile.Schedules.Clear();
                        profile.Schedules        = schedules;
                        profile.AllowAttachments = model.AllowAttachments;
                    }
                    _repository.SaveChanges();
                    UpdateSchedules(profile);
                    ChatServices.UpdateRefreshWatch();
                    return(Json(new { success = true, message = "Profile updated successfully!" }));
                }
            }
            catch (Exception)
            {
            }
            model.Logos = GetLogos();
            var workgroupList = _repository.Workgroups.Where(w => w.IsAssignable).Select(w => new SelectListItem
            {
                Text     = w.DisplayName,
                Value    = w.WorkgroupId.ToString(),
                Selected = w.WorkgroupId == model.Workgroup
            }).ToList();
            var templateList = _repository.Templates.Select(t => new SelectListItem
            {
                Text     = t.Title,
                Value    = t.TemplateId.ToString(),
                Selected = t.TemplateId == model.Template
            }).ToList();
            var widgetList = !_repository.Widgets.Any() ? new List <SelectListItem>() : _repository.Widgets.Select(w => new SelectListItem
            {
                Text     = w.Name,
                Value    = w.WidgetId.ToString(),
                Selected = w.WidgetId == model.Widget
            }).ToList();
            var skillsList = !_repository.Skills.Any(s => s.IsAssignable) ? new List <Skill>() : _repository.Skills.Where(s => s.IsAssignable).ToList();

            var schedulesList = !_repository.Schedules.Any(s => s.IsAssignable) ? new List <Schedule>() : _repository.Schedules.Where(s => s.IsAssignable).ToList();

            model.SchedulesList = schedulesList;
            model.SkillsList    = skillsList;
            model.WorkgroupList = workgroupList;
            model.TemplateList  = templateList;
            model.WidgetList    = widgetList;
            return(PartialView("_CreateProfile", model));
        }