public IActionResult AddColor(int noteID, ColorRequest color) { try { bool success = false, data; string message; var idClaim = HttpContext.User.Claims.FirstOrDefault(id => id.Type.Equals("id", StringComparison.InvariantCultureIgnoreCase)); int userId = Convert.ToInt32(idClaim.Value); data = _userNoteBusiness.AddColor(userId, noteID, color); if (data) { success = true; message = "Color Set Successfully"; return(Ok(new { success, message })); } else { message = "Try Again!"; return(Ok(new { success, message })); } } catch (Exception ex) { return(BadRequest(new { ex.Message })); } }
public void ChangeColor(int red, int green, int blue, int duration = -1, bool isStaticColorPriority = true) { if (!IsConnected()) { return; } int priority = coreObject.hyperionPriorityStaticColor; if (!isStaticColorPriority) { priority = coreObject.hyperionPriority; } ColorRequest colorRequest = ColorRequest.CreateBuilder() .SetRgbColor((red * 256 * 256) + (green * 256) + blue) .SetPriority(priority) .SetDuration(duration) .Build(); HyperionRequest request = HyperionRequest.CreateBuilder() .SetCommand(HyperionRequest.Types.Command.COLOR) .SetExtension(ColorRequest.ColorRequest_, colorRequest) .Build(); SendRequest(request); }
public MessageModel SendArgbColorCommand(ColorRequest request) { ColorModel color; Int32 colorValue; if (request.rgba.Length < 3 || request.rgba.Length > 4) { throw new Exception("Invalid rgba format"); } if (request.rgba.Length < 4) { colorValue = Color.FromArgb(request.rgba[0], request.rgba[1], request.rgba[2]).ToArgb(); } else { colorValue = Color.FromArgb(request.rgba[3], request.rgba[0], request.rgba[1], request.rgba[2]).ToArgb(); } switch (request.displaySetting) { case 1: color = new ColorModel(colorValue, ColorDisplaySetting.Disolve); break; default: color = new ColorModel(colorValue, ColorDisplaySetting.Cut); break; } return(comandSender.SendMessage(color.message)); }
public async Task <IHttpActionResult> SendColorMessage([FromBody] ColorRequest colorRequest) { try { var m = colorService.SendArgbColorCommand(colorRequest); return(Ok(m)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public async Task <ActionResult> SendColorMessage([FromForm] ColorRequest request) { try { var m = await colorService.SendArgbColorCommand(request); return(Ok(m)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public bool AddColor(int userID, int noteID, ColorRequest color) { try { var userData = _context.UserNotes.FirstOrDefault(user => user.UserId == userID && user.NotesId == noteID); if (userData != null) { userData.Color = color.Color; _context.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { throw new Exception(ex.Message); } }
public IActionResult GetAllPaging(ColorRequest request) { var model = _colorService.GetAllPaging(request); return(new OkObjectResult(model)); }
public async Task <IActionResult> GetAllPaging(ColorRequest request) { var model = await _colorService.GetAllPaging(request); return(new OkObjectResult(model)); }
public bool AddColor(int userID, int noteID, ColorRequest color) { bool responseData = _userNoteRepository.AddColor(userID, noteID, color); return(responseData); }
public async Task <BaseReponse <ModelListResult <ColorViewModel> > > GetAllPaging(ColorRequest request) { var query = await _colorRepository.FindAll(); if (!string.IsNullOrEmpty(request.SearchText)) { query = query.Where(x => x.Name.Contains(request.SearchText)); } int totalRow = query.Count(); var data = query.OrderByDescending(x => x.Id) .Skip((request.PageIndex) * request.PageSize) .Take(request.PageSize); var items = new ColorViewModel().Map(data).ToList(); return(new BaseReponse <ModelListResult <ColorViewModel> > { Data = new ModelListResult <ColorViewModel>() { Items = items, Message = Message.Success, RowCount = totalRow, PageSize = request.PageSize, PageIndex = request.PageIndex }, Message = Message.Success, Status = (int)QueryStatus.Success }); }