public async Task <CalificacionDesafioViewModel> Get_Desafio( int estId, int cursoId, int desafioId) { var curso = await _data.Find_Curso(cursoId); if (curso == null || !curso.ContieneEstudiante(estId) || !curso.ContieneDesafio(desafioId)) { throw new ApplicationServicesException(""); } var model = await _data.Find_RegistroCalificacion( cursoId, estId, desafioId); if (model == null) { model = new RegistroCalificacion() { CursoId = cursoId, DesafioId = desafioId, EstudianteId = estId, Calificaciones = new List <Calificacion>() }; _data.Add(model); if (!await _data.SaveAllAsync()) { throw new ApplicationServicesException(""); } } return(new CalificacionDesafioViewModel(model)); }
public async Task <ApiResult <CalificacionInfoViewModel> > Do_AddCalificacion (int idEst, int idCurso, int idDesafio) { var registroCalificacion = await _data.Find_RegistroCalificacion(idCurso, idEst, idDesafio); if (registroCalificacion == null) { throw new ApiNotFoundException("Recurso no encontrado"); } if (registroCalificacion.Iniciada) { throw new ApiBadRequestException("Debes terminar la calificación actual para poder registrar una nueva."); } var model = new Calificacion() { Tiempoinicio = null, CursoId = idCurso, EstudianteId = idEst, DesafioId = idDesafio }; _data.Add(model); var success = await _data.SaveAllAsync(); return(ApiResult <CalificacionInfoViewModel> .Initialize(model.ToViewModel(), success)); }
public void AddUserTest() { User user = new User() { Age = 23, Name = NOMBRE_USUARIO, Agendas = new List <Agenda>() }; dataAccess.Add(user); }
public async Task <ApiResult <CreateCalificacionCualitativaViewModel> > Do_Calificar(int idProf, int idCurso, int idEstudiante, int idDesafio, CreateCalificacionCualitativaViewModel model) { if (!await _data.Exist_Desafio(idDesafio, idCurso, idProf)) { throw new ApiNotFoundException("Recurso no encontrado"); } var estUserId = (await _usrService .Get_EstudianteUserId(idEstudiante)).GetValueOrDefault(); var desafio = await _data.Find_Desafio(idDesafio); var curso = await _data.Find_Curso(idCurso); _data.Add(model.Map()); //Mover //_data.Do_PushNotification( // NotificationType.NotificationDesafioCalificado, estUserId, // new Dictionary<string, string> // { // ["IdCurso"] = $"{idCurso}", // ["IdDesafio"] = $"{idDesafio}", // ["NombreDesafio"] = desafio.Nombre, // ["NombreCurso"] = curso.Nombre // }); var success = await _data.SaveAllAsync(); return(ApiResult <CreateCalificacionCualitativaViewModel> .Initialize(model, success)); }
public void AgregarAgendaTest() { Agenda agendaC = new Agenda() { Name = NOMBRE_AGENDA, Owner = new User() { Age = 99, Name = NOMBRE_USUARIO, Agendas = new List <Agenda>() }, Contacts = new List <User>() }; dataAccessAgenda.Add(agendaC); }
public async Task <bool> Do_Calificar(int idProf, int idCurso, int idEstudiante, int idDesafio, CalificarViewModel model) { if (!await _data.Exist_Desafio(idDesafio, idCurso, idProf)) { return(false); } var estUserId = (await _usrService .Get_EstudianteUserId(idEstudiante)).GetValueOrDefault(); var desafio = await _data.Find_Desafio(idDesafio); var curso = await _data.Find_Curso(idCurso); _data.Add(model.Map()); _data.Do_PushNotification( NotificationType.NotificationDesafioCalificado, estUserId, new Dictionary <string, string> { ["IdCurso"] = $"{idCurso}", ["IdDesafio"] = $"{idDesafio}", ["NombreDesafio"] = desafio.Nombre, ["NombreCurso"] = curso.Nombre }); return(await _data.SaveAllAsync()); }
public void Create(ProductDTO product) { product.Product_Id = _productDataAccess.Read().Count() + 1; _productDataAccess.Add(new Product() { PRODUCT_ID = product.Product_Id, DESCRIPTION = product.Description, Name = product.Name }); }
public void Add(ServiceSkill skill) { _database.Add(_mapper.Map <ServiceSkill, Skill>(skill)); var skillAdded = _database.GetSkills().Last(); _database.Add(_mapper.Map <ServiceSkillLevel, SkillLevel>(new ServiceSkillLevel() { SkillId = skillAdded.SkillId, Description = skill.Level1Description, LevelId = 1 })); _database.Add(_mapper.Map <ServiceSkillLevel, SkillLevel>(new ServiceSkillLevel() { SkillId = skillAdded.SkillId, Description = skill.Level2Description, LevelId = 2 })); _database.Add(_mapper.Map <ServiceSkillLevel, SkillLevel>(new ServiceSkillLevel() { SkillId = skillAdded.SkillId, Description = skill.Level3Description, LevelId = 3 })); _database.Add(_mapper.Map <ServiceSkillLevel, SkillLevel>(new ServiceSkillLevel() { SkillId = skillAdded.SkillId, Description = skill.Level4Description, LevelId = 4 })); }
public Person SavePerson(string firstName, string lastName, DateTime birthDate, int age) { if (string.IsNullOrWhiteSpace(firstName) || string.IsNullOrWhiteSpace(lastName) || age <= 0) { throw new ArgumentException("person's data are incorrect"); } Person person = new Person { FirstName = firstName, LastName = lastName, BirthDate = birthDate, Age = age, Addresses = new List <Address>(), Medals = new List <Medal>() }; if (_dataAccess.Add(person)) { return(person); } else { throw new InvalidOperationException("error during person saving"); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { FileStream Stream = new FileStream(fullpath, FileMode.Open, FileAccess.Read); StreamReader Reader = new StreamReader(Stream); Byte[] ImgData = new Byte[Stream.Length - 1]; Stream.Read(ImgData, 0, (int)Stream.Length - 1); test t = new test(); t.image = ImgData; _ser.Add(t); MessageBox.Show(""); }
public void AddUser(object param) { // save to database _dao.Add(NewUser); // reset the view NewUser = new User(); OnPropertyChanged("NewUserName"); OnPropertyChanged("NewUserID"); OnPropertyChanged("NewUserPassword"); RefreshUsers(); }
public IActionResult Post(string nome, string email, string profissao, string cidade, string estado, int empresa, bool ehAluno) { var lead = new Lead { Nome = nome, Email = email, Profissao = profissao, Cidade = cidade, Estado = estado, Empresa = (Organizations)empresa, EhAluno = ehAluno }; var resultado = _repositorio.Add(lead); return(RetorneResultadoDaOperacao(lead, resultado, "Não foi possível realizar o cadastro")); }
public void AddClient(object param) { // save to database _dao.Add(NewClient); // reset the view NewClient = new Client(); OnPropertyChanged("NewClientName"); OnPropertyChanged("NewClientContact"); OnPropertyChanged("NewClientPhone"); OnPropertyChanged("NewClientEmail"); OnPropertyChanged("NewClientStatus"); SelectedStateOption = Statuses.First(); RefreshClients(); }
public void AddUser(object param) { // validate stuff TBD // save to database TBD _dao.Add(NewUser); // add client to list _users.Add(NewUser); OnPropertyChanged("Users"); // reset the view NewUser = new User(); OnPropertyChanged("NewUserName"); OnPropertyChanged("NewUserID"); OnPropertyChanged("NewUserPassword"); ////RefreshUsers(); }
public void AddJob(object param) { // save to database _dao.Add(NewJob); // reset the form NewJob = new Job(); SelectedClient = null; NewClientName = null; NewDefaultHeight = null; NewJobDescription = null; NewJobName = null; NewMarkupPct = null; NewSalesTax = null; RefreshJobs(); }
public void AgregarDosAgendasAUser() { Agenda agenda1 = new Agenda() { Name = NOMBRE_AGENDA, Owner = new User() { Age = 99, Name = NOMBRE_USUARIO, Agendas = new List <Agenda>() }, Contacts = new List <User>() }; Agenda agenda2 = new Agenda() { Name = NOMBRE_AGENDA_2, Owner = new User() { Age = 99, Name = NOMBRE_USUARIO, Agendas = new List <Agenda>() }, Contacts = new List <User>() }; List <Agenda> agendas = new List <Agenda>(); agendas.Add(agenda1); agendas.Add(agenda2); User user1 = new User() { Name = NOMBRE_USUARIO, Age = 22, Agendas = agendas }; dataAccessUsuario.Add(user1); }
public bool Create(TblUser user) { bool result = false; try { if (user == null) { return(result); } this.context.Database.AutoTransactionsEnabled = true; result = userAccess.Add(user); } catch (Exception e) { //Console.WriteLine(e); //throw; } return(result); }
public void Create(PriceDTO price) { price.Price_Id = _priceDataAccess.Read().Count() + 1; Product entity = _productDataAccess.Read().Where(x => x.Name == price.product.Name).FirstOrDefault(); _priceDataAccess.Add(new Price() { PriceId = price.Price_Id, PriceToConvert = price.PriceToConvert, FromCurrency = price.FromCurrency, ToCurrency = price.ToCurrency, ExchangedValue = price.ExchangedValue, DefaultValue = price.DefaultValue, Date = DateTime.Today, Shop = price.Shop, PicturePathId = price.PicturePathId, PRODUCT_ID = price.Product_Id, product = entity == null ? new Product() { DESCRIPTION = price.product.Description, PRODUCT_ID = price.Product_Id, Name = price.product.Name } :entity }); }
public void Add() { _ida.Add(); }
/// <summary> /// 添加 /// </summary> /// <param name="datas">数据</param> protected void Add(params ET[] datas) { UnitOfWork.UnitOfWork.RegisterCommand(dataAccess.Add(datas).ToArray()); }
public int Add(int a, int b) { return(_dataAccess.Add(a, b)); }
/// <summary> /// 插入一个实体 /// </summary> /// <typeparam name="T">表实体</typeparam> /// <param name="entity">实体内容</param> /// <param name="pk">要忽略的主键</param> /// <returns>long</returns> public static long Add <T>(T entity, Expression <Func <T, object> > pk = null) where T : class, new() { return(_dataAccess.Add(entity, pk)); }
/// <summary> /// 添加订单 /// </summary> public void Add() { // 业务验证。。。。。 dal.Add(); }