public MissionView(Mission model)
        {
            Mapper.CreateMap<Mission, MissionView>();
            Mapper.Map<Mission, MissionView>(model, this);

            this.created = model.created.ToString().Replace('T', ' ');
            this.updated = model.updated.ToString().Replace('T', ' ');
            this.date = model.date == null ? String.Empty : model.date.ToString();
            this.categoryIds = model.categories.Select(c => c.id).ToArray();
        }
 public Mission createMission(Mission model)
 {
     db.missions.Add(model);
     db.SaveChanges();
     return model;
 }
        public Mission getModel(IRepository repo)
        {
            var model = new Mission();

            Mapper.CreateMap<MissionView, Mission>();
            Mapper.Map<MissionView, Mission>(this, model);

            if (this.customerId != null) { model.customer = repo.getCustomer((int)this.customerId); }
            if (this.categoryIds.Length > 0) { model.categories = repo.getCategories(this.categoryIds).ToArray(); }

            return model;
        }