public ActionResult Create(FormModels.Register.Promouter model)
        {
            if (ModelState.IsValid)
            {
                //salt
                model.Password = Password.MakePassword(model.Password, DateTime.UtcNow);
                var binder = new RegisterPromouterToUsers();
                var entry = new PromouterUser();
                binder.Load(model, entry);

                DataAccessLayer.Create(entry);
                DataAccessLayer.DbContext.SaveChanges();

                return RedirectToAction("Detail", new { id = entry.Id });
            }

            return View(model);
        }
Example #2
0
        public ActionResult Edit(Promouter model)
        {
            if (ModelState.IsValid)
            {
                var allAttributes = DataAccessLayer.GetAllAttributes();
                var editor = new PromouterEditor(allAttributes);
                var user = new PromouterUser();
                editor.Edit(model, user);
                DataAccessLayer.DbContext.SaveChanges();
                return Detail(model.UserId);
            }

            #if DEBUG
            throw new Exception("ModelState is invalid");
            #endif
            #if RELEASE
            return new EmptyResult();
            #endif
        }
Example #3
0
        public void Edit(Promouter source, PromouterUser dest)
        {
            //source.Email = dest.Email;

            var checklist = dest.Checklists.FirstOrDefault();
            if (checklist == null)
            {
            #if DEBUG
                throw new HttpException(404, "Checklist not found");
            #endif
            #if RELEASE
                return;
            #endif
            }

            checklist.AttrbuteValues.Clear();

            foreach (var attribute in Attributes)
            {
                var attributeValue = new AttribValue
                {
                    AttribId = attribute.Id,
                    ChecklistId = checklist.Id
                };

                #region Big switch [TODO by code field]
                switch (attribute.Name)
                {
                    case "Фамилия":
                        //TODO
                        break;
                    case "Имя":
                        attributeValue.Value = source.Name;
                        break;
                    case "Отчество":
                        //TODO
                        break;
                    case "Пол":
                        //TODO
                        break;
                    case "Дата рождения":
                        attributeValue.Value = source.BirthDate.ToPandaString();
                        break;
                    case "Медицинская книжка":
                        attributeValue.Value = source.MedicalBook.ToPandaString();
                        break;
                    case "Автомобиль":
                        attributeValue.Value = source.Car.ToPandaString();
                        break;
                    case "Готов работать сейчас":
                        //TODO
                        break;
                    case "Мобильный телефон":
                        attributeValue.Value = source.MobilePhone;
                        break;
                    case "Цена работы за час":
                        attributeValue.Value = source.CostForHour.ToPandaString();
                        break;
                    case "Город":
                        attributeValue.Value = source.City;
                        break;
                    case "Образование":
                        attributeValue.Value = source.Education;
                        break;
                    case "Опыт работы":
                        //TODO
                        break;
                    case "Рост":
                        attributeValue.Value = source.Height.ToPandaString();
                        break;
                    case "Телосложение":
                        attributeValue.Value = source.Build;
                        break;
                    case "Вес":
                        attributeValue.Value = source.Weight.ToPandaString();
                        break;
                    case "Тип кожи":
                        attributeValue.Value = source.SkinType;
                        break;
                    case "Цвет глаз":
                        attributeValue.Value = source.EyeColor;
                        break;
                    case "Цвет волос":
                        attributeValue.Value = source.HairColor;
                        break;
                    case "Длина волос":
                        attributeValue.Value = source.HairLength;
                        break;
                    case "Размер одежды":
                        attributeValue.Value = source.SizeClothes;
                        break;
                    case "Размер обуви":
                        attributeValue.Value = source.SizeShoes;
                        break;
                    case "Размер груди":
                        attributeValue.Value = source.SizeChest;
                        break;
                    case "Роликовые коньки":
                        attributeValue.Value = source.RollerSkates.ToPandaString();
                        break;
                    case "Зимние коньки":
                        attributeValue.Value = source.WinterSkates.ToPandaString();
                        break;
                }
                #endregion

                checklist.AttrbuteValues.Add(attributeValue);
            }
        }
Example #4
0
        public void Edit(PromouterForm source, PromouterUser dest)
        {
            dest.Email = source.Email;
            dest.IsAdmin = source.IsAdmin;
            var checklist = dest.MainChecklist;
            if (checklist == null)
            {
            #if DEBUG
                throw new HttpException(404, "Checklist not found");
            #endif
            #if RELEASE
                return;
            #endif
            }

            var mainAlbum = dest.Albums.First();
            if (source.NewPhotos != null)
            {
                foreach (var photo in source.NewPhotos)
                {
                    DataAccessLayer.Create(new Photo
                    {
                        Album = DataAccessLayer.GetById<Album>(mainAlbum.Id),
                        SourceUrl = ImageCreator.SavePhoto(photo)
                    });
                }
            }

            DataAccessLayer.ClearChecklist(checklist);

            foreach (var attribute in DataAccessLayer.GetAttributes(DataAccessLayer.Constants.PromouterChecklistType.Id))
            {
                var attributeValue = new AttribValue
                {
                    AttribId = attribute.Id,
                    ChecklistId = checklist.Id
                };

                #region Big switch [TODO by code field]
                switch (attribute.Code)
                {
                    case Constants.LastNameCode:
                        attributeValue.Value = source.LastName;
                        break;
                    case Constants.FirstNameCode:
                        attributeValue.Value = source.FirstName;
                        break;
                    case Constants.MiddleNameCode:
                        attributeValue.Value = source.MiddleName;
                        break;
                    case Constants.GenderCode:
                        attributeValue.Value = source.Gender;
                        break;
                    case Constants.DateOfBirthCode:
                        attributeValue.Value = source.BirthDate.ToPandaString();
                        break;
                    case Constants.MedicalBookCode:
                        attributeValue.Value = source.MedicalBook.ToString();
                        break;
                    case Constants.CarCode:
                        attributeValue.Value = source.Car.ToString();
                        break;
                    case Constants.ReadyForWorkCode:
                        attributeValue.Value = source.ReadyForWork.ToString();
                        break;
                    case Constants.MobilePhoneCode:
                        attributeValue.Value = source.MobilePhone;
                        break;
                    case Constants.SalaryCode:
                        attributeValue.Value = source.Salary;
                        break;
                    case Constants.CityCode:
                        attributeValue.Value = source.City;
                        break;
                    case Constants.EducationCode:
                        attributeValue.Value = source.Education;
                        break;
                    case Constants.WorkExperienceCode:
                        attributeValue.Value = editWorkExperience(source);
                        break;
                    case Constants.HeightCode:
                        attributeValue.Value = source.Height.ToPandaString();
                        break;
                    case Constants.BuildCode:
                        attributeValue.Value = source.Build;
                        break;
                    case Constants.WeightCode:
                        attributeValue.Value = source.Weight.ToString(CultureInfo.InvariantCulture);
                        break;
                    case Constants.SkinTypeCode:
                        attributeValue.Value = source.SkinType;
                        break;
                    case Constants.EyeColorCode:
                        attributeValue.Value = source.EyeColor;
                        break;
                    case Constants.HairColorCode:
                        attributeValue.Value = source.HairColor;
                        break;
                    case Constants.HairLengthCode:
                        attributeValue.Value = source.HairLength;
                        break;
                    case Constants.SizeClothesCode:
                        attributeValue.Value = source.SizeClothes;
                        break;
                    case Constants.SizeShoesCode:
                        attributeValue.Value = source.SizeShoes;
                        break;
                    case Constants.SizeChestCode:
                        attributeValue.Value = source.SizeChest;
                        break;
                    case Constants.RollerSkatesCode:
                        attributeValue.Value = source.RollerSkates.ToString();
                        break;
                    case Constants.WinterSkatesCode:
                        attributeValue.Value = source.WinterSkates.ToString();
                        break;
                    case Constants.AboutCode:
                        attributeValue.Value = source.About;
                        break;
                    case Constants.HobbiesCode:
                        attributeValue.Value = source.Hobbies;
                        break;
                    case Constants.DesiredWorkTimeCode:
                        attributeValue.Value = editDesiredWorkTime(source);
                        break;
                    case Constants.DesiredWorkCode:
                        attributeValue.Value = editDesiredWork(source);
                        break;
                }
                #endregion

                checklist.AttrbuteValues.Add(attributeValue);
            }
        }