public IHttpActionResult PostDisco(Disco disco) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Discoes.Add(disco); try { db.SaveChanges(); } catch (DbUpdateException) { if (DiscoExists(disco.IdDisco)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = disco.IdDisco }, disco)); }
public IHttpActionResult PutDisco(int id, Disco disco) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != disco.IdDisco) { return(BadRequest()); } db.Entry(disco).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!DiscoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
//Nos delvovera una lista de objetos tipo ADisco //Pra mostrarlos en el formulario principal public List <Disco> ListarDisco() { List <Disco> listaDisco = new List <Disco>(); //Abrimos la conexion a la base de datos //para poder realizar la consulta SqlConnection conexion = obtenerConexion(); //Consulta que obtendra tods los elementos de la tabla string consulta = "SELECT* FROM TblDisco"; //Ejecucion de la consulta en la base de datos SqlCommand comando = new SqlCommand(consulta, conexion); SqlDataReader reader = comando.ExecuteReader(); //Para que lea todas las filas usamos el HasRows if (reader.HasRows) { while (reader.Read()) { //Obtenemos los datos cada fila y lo almacenamos //en los atributos del artista Disco disco = new Disco(); disco.idDisco = reader.GetInt32(0); disco.idArtista = reader.GetInt32(1); disco.nombreDisco = reader.GetString(2); disco.anoPublicacion = reader.GetInt32(3); disco.sumatoria = reader.GetInt32(4); disco.puntuacion = reader.GetInt32(5); listaDisco.Add(disco); } } return(listaDisco); }
public ModificarStock(string discoId) { InitializeComponent(); discosRepositorio = new DiscosRepositorio(); ajustesRepositorio = new AjustesRepositorio(); disc = discosRepositorio.ObtenerDisco(discoId); }
public async Task InsertDiscs() { if (_discoRepository.Any()) { return; } var token = await GetToken(); var listGeneros = typeof(GeneroEnum).GetEnumValuesWithDescription(); var listDisco = Disco.ListEmpty(); foreach (var item in listGeneros) { var list = await GetDiscsByGenre(token, item); listDisco.AddRange(list); } try { _discoRepository.AddList(listDisco); } catch (Exception ex) { ExceptionData.GetInfoDataException("Disco", ex); } }
public void Consulta_disco_por_identificador() { var id = 1; Disco disco = _discoController.Get(id).Value; Assert.AreEqual(id, disco.Id); }
public static void Main(string[] args) { DateTime?timeOfLastException = null; while (true) { try { ITrafficLightControl control = new Disco(new TrafficLightInterface()); control.Activate(); } catch (Exception e) { /* * Sometimes the connection to the traffic light interface is interrupted, e.g. by power cycling. * By catching the exception here, we can try to recreate the TrafficLightInterface and continue, * rather than having to terminate the program. However, if there's another issue which will cause * exceptions to be continually thrown, then we should give up and terminate. */ var currentDateTime = DateTime.UtcNow; if (timeOfLastException.HasValue && (currentDateTime - timeOfLastException.Value).TotalMinutes < 1) { throw e; } timeOfLastException = currentDateTime; } } }
public void EditDisco(Disco disco) { disco.DataUltimaAtualizacao = DateTime.Now; this._appcontext.Disco.Update(disco); this._appcontext.Entry(disco).State = Microsoft.EntityFrameworkCore.EntityState.Modified; this._appcontext.SaveChanges(); }
public void DeleteDisco(string id) { Disco disco = GetDisco(id); this._appcontext.Entry(disco).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; this._appcontext.SaveChanges(); }
public void Busca_disco_pelo_identificador() { var id = 1; Disco disco = _discoRepository.Get(id); Assert.AreEqual(id, disco.Id); }
void IRepositorioDisco.CreateDisco(Disco disco) { disco.DataInclusao = DateTime.Now; this._appcontext.Disco.Add(disco); this._appcontext.Entry(disco).State = Microsoft.EntityFrameworkCore.EntityState.Added; this._appcontext.SaveChanges(); }
public Disco GetDiscosId(string id, GeneroMusical genero) { Item item = GetDiscosSpotifyId(id, genero); if (item != null) { Disco disco = new Disco(); disco.Id = item.id; disco.Nome = item.name; disco.Ano = item.release_date.Substring(0, 4); disco.href = item.href; disco.Imagem = item.images.Select(s => s.url).Last(); //disco.Preco = CashBack.Preco(genero); //disco.CashBack = CashBack.ValorDia(genero); disco.Genero = genero; return(disco); } else { Disco disco = new Disco { Id = "NãoDefinido" }; //List<Disco> ret = new List<Disco>(); //ret.Add(disco); return(disco); } }
public ActionResult GuardarDisco(Disco disco) { DiscoRepositorio discoRepo = new DiscoRepositorio(); discoRepo.GuardarDisco(disco); return(View()); }
public bool AtualizarDisco(Disco novoDisco) { _local.discos.Attach(novoDisco); _local.Entry(novoDisco).State = EntityState.Modified; _local.SaveChanges(); return(true); }
public ActionResult <string> Get(string id) { Disco discos = _appDisco.GetById(id); return(Ok(discos));// new string[] { "value1", "value2" }; //return "value"; }
private void AdicionarAlbunsSpotify(ApplicationDbContext context) { SpotifyService spotify = new SpotifyService(); TokenSpotify token = spotify.ObterTokenSpotify(); if (token != null && !string.IsNullOrWhiteSpace(token.access_token)) { string[] generos = new string[] { "pop", "rock", "classical", "jazz" }; foreach (string genero in generos) { RetornoAlbunsSpotify.RootObject albunsSpotify = spotify.ObterListaAlbuns(token, genero); if (albunsSpotify != null && albunsSpotify.playlists != null) { string generoBanco = string.Empty; switch (genero) { case "pop": generoBanco = "POP"; break; case "classical": generoBanco = "CLASSIC"; break; case "rock": generoBanco = "ROCK"; break; default: generoBanco = "MPB"; break; } if (albunsSpotify.playlists.items.Any()) { foreach (var item in albunsSpotify.playlists.items) { Disco disco = new Disco() { Genero = generoBanco, Nome = item.name }; Random randNum = new Random(); decimal valorVenda = randNum.Next(10, 100); double centavos = randNum.NextDouble(); disco.PrecoVenda = valorVenda + decimal.Round((decimal)centavos, 2); context.CatalogoDiscos.Add(disco); } context.SaveChanges(); } } } } }
public ActionResult DeleteConfirmed(int id) { Disco disco = db.Discoes.Find(id); db.Discoes.Remove(disco); db.SaveChanges(); return(RedirectToAction("Index")); }
public void PutDisco(Disco disco) { //disco.Id = id; if (!repositorio.Update(disco)) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
public ActionResult CreateDisco(Disco disco) { if (ModelState.IsValid) { discosService.CreateDisco(disco); return(RedirectToAction("Index")); } return(View()); }
public void Post(Disco disco) { // El Specification tambien se puede usar para hacer validacionoes y no solo filtrar un IEnumerable if (!new EspañolSpecification().IsSatisfiedBy(disco)) { throw new Exception("El disco no es de idioma español"); } }
public static _ComponentModel FromJobComponent(Disco.Models.Repository.JobComponent jc) { return new _ComponentModel { Id = jc.Id, Description = jc.Description, Cost = jc.Cost.ToString("C") }; }
static void QueryTwo() { //Affichez la liste de tous les albums sur lesquels un Artiste joue du trombone. Disco d = new Disco(); d.Albums.OrderBy(album => album.Titre) .Where(album => album.SideMen.Any(artist => artist.Value == "trombone")) .ToList().ForEach(album => WriteLine(album)); }
public IActionResult EditDisco(string id, [FromServices] DiscoBusiness discoBusiness) { Disco disco = discoBusiness.GetDisco(id); DiscosViewModel vm = new DiscosViewModel(); vm.disco = disco; return(View(vm)); }
public ModificarDisco(string discoId) { InitializeComponent(); discosRepositorio = new DiscosRepositorio(); interpretesRepositorio = new InterpretesRepositorio(); selloRepositorio = new SelloRepositorio(); generosRepositorio = new GenerosRepositorio(); disc = discosRepositorio.ObtenerDisco(discoId); }
public HttpResponseMessage PostDisco(Disco item) { item = repositorio.Add(item); var response = Request.CreateResponse <Disco>(HttpStatusCode.Created, item); string uri = Url.Link("DefaultApi", new { id = item.Id }); response.Headers.Location = new Uri(uri); return(response); }
public ActionResult Edit([Bind(Include = "ID_Disco,Nombre_Disco")] Disco disco) { if (ModelState.IsValid) { db.Entry(disco).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(disco)); }
public Disco GetDisco(int id) { Disco item = repositorio.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(item); }
public Response Comprar(PedidoDto pedidoDto, int clienteId) { try { var listItemVenda = ItemVenda.ListEmpty(); var discos = Disco.ListEmpty(); #region Validation if (pedidoDto.IsNotValid()) { return(Response.BuildBadRequest()); } var cliente = _clienteRepository.ObterPorId(clienteId); if (cliente == null) { return(Response.BuildBadRequest(ExceptionMessages.ClienteNaoEncontrado)); } discos = _discoRepository.ObterListaPorId(pedidoDto.GetListId()); if (!discos.Any()) { return(Response.BuildBadRequest(ExceptionMessages.DiscoNaoEncontrado)); } #endregion foreach (var disco in discos) { var pedidoItem = pedidoDto.ItemPedidoDto.Where(i => i.DiscoId == disco.DiscoId).FirstOrDefault(); var cashback = PorcentagemCachbackFactory. CriaInstanciaPorcentagemCashback((GeneroEnum)_generoRepository.ObterPorId(disco.Genero.GeneroId).GeneroId) .CalculaValorCashbackPorGenero(DateTime.Now.DayOfWeek); listItemVenda.Add(ItemVenda.Build(pedidoItem.Quantidade, cashback, disco)); } var venda = _vendaRepository.Add(Venda.Build(cliente, listItemVenda)); if (!_unitOfWork.Commit()) { Response.BuildBadRequest(ExceptionMessages.ErroAoSalvarDados); } return(Response.BuildSuccess(_mapper.Map <VendaDto>(venda))); } catch (Exception ex) { return(Response.BuildInternalServerError(ex.Message)); } }
public void DeleteDisco(int id) { Disco item = repositorio.Get(id); if (item == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } repositorio.Remove(id); }
public Disco Get(long id) { var disco = new Disco(); _action.Open(conn => { var query = $"select * from {_tableDisco} where id = @id"; disco = conn.Query <Disco>(query, new { id }).FirstOrDefault(); }); return(disco); }
public static _DeviceModel FromDeviceModel(Disco.Models.Repository.DeviceModel dm) { return new _DeviceModel() { Id = dm.Id, Description = dm.Description, Manufacturer = dm.Manufacturer, Model = dm.Model, ModelType = dm.ModelType }; }
public ActionResult Create([Bind(Include = "ID_Disco,Nombre_Disco")] Disco disco) { if (ModelState.IsValid) { db.Discoes.Add(disco); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(disco)); }
public static _ComponentModel FromDeviceComponent(Disco.Models.Repository.DeviceComponent dc) { return new _ComponentModel { Id = dc.Id, Description = dc.Description, Cost = dc.Cost.ToString("C"), JobSubTypes = dc.JobSubTypes.Select(j => string.Format("{0}_{1}", j.JobTypeId, j.Id)).ToList() }; }
public static _CommentModel FromJobLog(Disco.Models.Repository.JobLog jl) { return new _CommentModel { Id = jl.Id, JobId = jl.JobId, AuthorId = jl.TechUserId, Author = jl.TechUser.ToString(), Timestamp = jl.Timestamp, Comments = jl.Comments, HtmlComments = jl.Comments.ToHtmlComment().ToString() }; }
public static _AttachmentModel FromAttachment(Disco.Models.Repository.DeviceAttachment da) { return new _AttachmentModel { ParentId = da.DeviceSerialNumber, Id = da.Id, AuthorId = da.TechUserId, Author = da.TechUser.ToStringFriendly(), Timestamp = da.Timestamp, Comments = da.Comments, DocumentTemplateId = da.DocumentTemplateId, DocumentTemplateDescription = da.DocumentTemplateId == null ? null : da.DocumentTemplate.Description, Filename = da.Filename, MimeType = da.MimeType }; }
public static _AttachmentModel FromAttachment(Disco.Models.Repository.JobAttachment ja) { return new _AttachmentModel { ParentId = ja.JobId.ToString(), Id = ja.Id, AuthorId = ja.TechUserId, Author = ja.TechUser.ToStringFriendly(), Timestamp = ja.Timestamp, Comments = ja.Comments, DocumentTemplateId = ja.DocumentTemplateId, DocumentTemplateDescription = ja.DocumentTemplateId == null ? null : ja.DocumentTemplate.Description, Filename = ja.Filename, MimeType = ja.MimeType }; }
protected void btAgregar_Click(object sender, EventArgs e) { if (validar()) { int idArtista = int.Parse(cbArtista.SelectedValue); Disco disco = new Disco(int.Parse(txId.Text), txNombre.Text, idArtista, int.Parse(txPrecio.Text)); if (!DAODisco.sqlInsert(disco)) { lbMensaje.Text = "Error. No se pudo agregar el disco, porque ya existe"; } else { lbMensaje.Text = "Disco agregado exitosamente"; } } }
partial void UpdateLocationModeOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Models.Services.Job.LocationModes LocationMode, bool redirect);
partial void AddJobOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, int JobId, string Comment, int? SLAExpiresMinutes, Disco.Models.Repository.JobQueuePriority Priority);
public override System.Web.Mvc.ActionResult UpdateLocationMode(Disco.Models.Services.Job.LocationModes LocationMode, bool redirect) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateLocationMode); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "LocationMode", LocationMode); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect); UpdateLocationModeOverride(callInfo, LocationMode, redirect); return callInfo; }
partial void UpdateOrganisationAddressOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Models.BI.Config.OrganisationAddress organisationAddress, bool redirect);
private void UpdateJobSubTypes(Disco.Models.Repository.JobQueue jobQueue, List<string> JobSubTypes) { Database.Configuration.LazyLoadingEnabled = true; // Remove All Existing if (jobQueue.JobSubTypes != null) { foreach (var st in jobQueue.JobSubTypes.ToArray()) jobQueue.JobSubTypes.Remove(st); } // Add New if (JobSubTypes != null && JobSubTypes.Count > 0) { var subTypes = new List<Disco.Models.Repository.JobSubType>(); foreach (var stId in JobSubTypes) { var typeId = stId.Substring(0, stId.IndexOf("_")); var subTypeId = stId.Substring(stId.IndexOf("_") + 1); var subType = Database.JobSubTypes.FirstOrDefault(jst => jst.JobTypeId == typeId && jst.Id == subTypeId); subTypes.Add(subType); } jobQueue.JobSubTypes = subTypes; } Database.SaveChanges(); }
partial void FileStoreOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Models.InitialConfig.FileStoreModel m);
partial void DatabaseOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Models.InitialConfig.DatabaseModel model);
partial void CreateOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Areas.Config.Models.UserFlag.CreateModel model);
public override System.Web.Mvc.ActionResult FileStore(Disco.Web.Models.InitialConfig.FileStoreModel m) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.FileStore); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "m", m); FileStoreOverride(callInfo, m); return callInfo; }
public override System.Web.Mvc.ActionResult Create(Disco.Web.Areas.Config.Models.AuthorizationRole.CreateModel model) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Create); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model); CreateOverride(callInfo, model); return callInfo; }
partial void LogRepairOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Models.Job.LogRepairModel m, System.Web.Mvc.FormCollection form);
public override System.Web.Mvc.ActionResult AddJob(int id, int JobId, string Comment, int? SLAExpiresMinutes, Disco.Models.Repository.JobQueuePriority Priority) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AddJob); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "JobId", JobId); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Comment", Comment); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "SLAExpiresMinutes", SLAExpiresMinutes); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Priority", Priority); AddJobOverride(callInfo, id, JobId, Comment, SLAExpiresMinutes, Priority); return callInfo; }
private void UpdateDescription(Disco.Models.Repository.DeviceModel deviceModel, string Description) { if (string.IsNullOrWhiteSpace(Description)) deviceModel.Description = null; else deviceModel.Description = Description; Database.SaveChanges(); }
private void UpdateDefaultRepairProvider(Disco.Models.Repository.DeviceModel deviceModel, string DefaultRepairProvider) { if (string.IsNullOrEmpty(DefaultRepairProvider)) { deviceModel.DefaultRepairProvider = null; } else { // Validate var RepairProvider = Plugins.GetPluginFeature(DefaultRepairProvider, typeof(RepairProviderFeature)); deviceModel.DefaultRepairProvider = RepairProvider.Id; } Database.SaveChanges(); }
private void UpdateDefaultPurchaseDate(Disco.Models.Repository.DeviceModel deviceModel, string DefaultPurchaseDate) { if (string.IsNullOrEmpty(DefaultPurchaseDate)) { deviceModel.DefaultPurchaseDate = null; } else { DateTime d; if (DateTime.TryParse(DefaultPurchaseDate, out d)) { deviceModel.DefaultPurchaseDate = d; } else { throw new Exception("Invalid Date Format"); } } Database.SaveChanges(); }
public override System.Web.Mvc.ActionResult LogRepair(Disco.Web.Models.Job.LogRepairModel m, System.Web.Mvc.FormCollection form) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.LogRepair); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "m", m); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "form", form); LogRepairOverride(callInfo, m, form); return callInfo; }
partial void AddOfflineOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Models.Device.AddOfflineModel m);
public override System.Web.Mvc.ActionResult AddOffline(Disco.Web.Models.Device.AddOfflineModel m) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AddOffline); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "m", m); AddOfflineOverride(callInfo, m); return callInfo; }
partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string DownloadId, Disco.Models.Services.Devices.Exporting.DeviceExportTypes? ExportType, int? ExportTypeTargetId);
partial void CreateOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Areas.Config.Models.AuthorizationRole.CreateModel model);
public override System.Web.Mvc.ActionResult Export(string DownloadId, Disco.Models.Services.Devices.Exporting.DeviceExportTypes? ExportType, int? ExportTypeTargetId) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DownloadId", DownloadId); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExportType", ExportType); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ExportTypeTargetId", ExportTypeTargetId); ExportOverride(callInfo, DownloadId, ExportType, ExportTypeTargetId); return callInfo; }
public override System.Web.Mvc.ActionResult Database(Disco.Web.Models.InitialConfig.DatabaseModel model) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Database); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model); DatabaseOverride(callInfo, model); return callInfo; }
public override System.Web.Mvc.ActionResult UpdateOrganisationAddress(Disco.Models.BI.Config.OrganisationAddress organisationAddress, bool redirect) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.UpdateOrganisationAddress); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "organisationAddress", organisationAddress); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect); UpdateOrganisationAddressOverride(callInfo, organisationAddress, redirect); return callInfo; }