using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace CRM.Models
{
public class LanguageList
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public ICollection<LanguageInfo> LanguageInfos { get; set; }
public LanguageList()
{
LanguageInfos = new List<LanguageInfo>();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace CRM.Models
{
public class LanguageInfo
{
[Key]
public int Id { get; set; }
[Required, Display(Name = "Уровень владения языком")]
public int SkillLevel { get; set; }
[Required, Display(Name = "Родной язык")]
public bool NativeLanguage { get; set; }
public int LanguageListId { get; set; }
public LanguageList LanguageList { get; set; }
public ICollection<BridgeLC> Categories { get; set; }
public ICollection<BridgeTL> Translators { get; set; }
public LanguageInfo()
{
Categories = new List<BridgeLC>();
Translators = new List<BridgeTL>();
}
public void AddCategory(CategoryInfo categoryInfo)
{
Categories.Add(new BridgeLC()
{
CategoryInfo = categoryInfo
});
}
public void AddCategory(int categoryInfoId)
{
Categories.Add(new BridgeLC()
{
CategoryInfoId = categoryInfoId
});
}
}
}
namespace CRM.ViewModels
{
public class TranslatorAdd
{
public Translator Translator { get; set; } = new Translator();
public LanguageInfo LanguageInfo { get; set; } = new LanguageInfo();
public CategoryInfo CategoryInfo { get; set; } = new CategoryInfo();
public LanguagePair LanguagePair { get; set; } = new LanguagePair();
public int TranslatorId
{
get { return Translator.Id; }
set { Translator.Id = value; }
}
public int LanguageInfoId
{
get { return LanguageInfo.Id; }
set { LanguageInfo.Id = value; }
}
public int CategoryInfoId
{
get { return CategoryInfo.Id; }
set { CategoryInfo.Id = value; }
}
public int LanguagePairId
{
get { return LanguagePair.Id; }
set { LanguagePair.Id = value; }
}
//[Display(Name = "Выберите язык")]
//public int LanguageId { get; set; }
//[Display(Name = "Уровень владения языком")]
//public int CategoryId { get; set; }
public SelectList LanguageSelectList { get; set; }
public SelectList CategorySelectList { get; set; }
public SelectList SpecialitySelectList { get; set; }
public List<SelectListItem> JobTypeSelectList { get; set; }
public List<SelectListItem> ExpertLevelList { get; set; }
SelectList Result { get; set; }
public void Init(LanguageListRepository languageListRepository,
CategoryListRepository categoryListRepository, SpecialityListRepository specialityListRepository)
{
int selectedIndex = 1;
LanguageSelectList = new SelectList(
languageListRepository.GetList(),
"Id", "Name");
CategorySelectList = new SelectList(
categoryListRepository.GetList(),
"Id", "Name", selectedIndex);
SpecialitySelectList = new SelectList(
specialityListRepository.GetListByCategoryId(selectedIndex),
"Id", "Name");
ExpertLevelList = new List<SelectListItem>()
{
new SelectListItem() { Text="Интересуюсь", Value="low"},
new SelectListItem() { Text="Часто использую в повседневной жизни", Value="medium"},
new SelectListItem() { Text="Есть опыт работы в данной области", Value="high"},
new SelectListItem() { Text="Есть проф. образование", Value="pro"},
};
JobTypeSelectList = new List<SelectListItem>()
{
new SelectListItem() { Text = "Письменный перевод", Value = "written translation"},
new SelectListItem() { Text = "Устный, последовательный перевод", Value = "Consecutive interpretation"},
new SelectListItem() { Text = "Устный, синхронный перевод", Value = "Simultaneous interpretation"},
new SelectListItem() { Text = "Редактура", Value = "editing"},
new SelectListItem() { Text = "Копирайтинг", Value = "Copywriting"},
new SelectListItem() { Text = "Контроль качества", Value = "Quality control"},
new SelectListItem() { Text = "Корректура", Value = "correction"},
};
}
}
}
<div class="tab-content">
<div class="tab-pane active" id="language_1">
<div class="mt-lg-5">
<div class="form-group row">
<div class="col-sm-6">
@Html.LabelFor(m => m.LanguageInfo.LanguageListId, new { @class = "col-form-label float-sm-right" })
</div>
<div class="col-sm-6">
@Html.DropDownListFor(m => m.LanguageInfoId, Model.LanguageSelectList, new { @class = "form-control" })
</div>
</div>
<div class="form-group row">
<div class="col-sm-6">
@Html.LabelFor(m => m.LanguageInfo.SkillLevel, new { @class = "col-form-label float-sm-right" })
</div>
<div class="col-sm-4">
@Html.EditorFor(m => m.LanguageInfo.SkillLevel, new
{
@class = "slider col-form-label float-sm-left",
@type = "number",
@min = 0,
@max = 100,
@step = 1
})
</div>
</div>
}