Exemplo n.º 1
0
        public JsonResult Delete(int id)
        {
            CreationYear creationYear = myService.GetById(id);

            myService.Delete(creationYear);
            myService.Commit();
            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult Edit(CreationYear cr)
        {
            CreationYear c = myService.GetById(cr.CreationYearID);

            c.Name   = cr.Name;
            c.Active = cr.Active;
            c.Cars   = cr.Cars;
            myService.Update(c);
            myService.Commit();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 3
0
        // GET: CreationYear/Edit/5
        public ActionResult Edit(int id)
        {
            CreationYear cr = myService.GetById(id);

            return(View(cr));
        }
Exemplo n.º 4
0
 public ActionResult Create(CreationYear cr)
 {
     myService.Add(cr);
     myService.Commit();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 5
0
        // GET: CreationYear/Details/5
        public ActionResult Details(int id)
        {
            CreationYear c = myService.GetById(id);

            return(View(c));
        }
Exemplo n.º 6
0
        public byte[] GetBytes()
        {
            uint WriteChunk(BinaryWriter writer, string tag, string data)
            {
                if (data is null)
                {
                    return(0);
                }

                var bytes = Encoding.Default.GetBytes(data + "\0").ToArray();

                if (bytes.Length % 2 != 0)
                {
                    Array.Resize(ref bytes, bytes.Length + 1);
                    bytes[bytes.Length - 1] = 0;
                }

                writer.Write(FourCC.FromString(tag));
                writer.Write((uint)bytes.Length);
                writer.Write(bytes);

                return((uint)(sizeof(uint) * 2 + bytes.Length));
            }

            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter writer = new BinaryWriter(stream, Encoding.Default, true)) {
                    writer.Write(FourCC.FromString("LIST"));
                    writer.Write((uint)0);             // ダミー値

                    writer.Write(FourCC.FromString("INFO"));

                    uint len = 0;
                    len += WriteChunk(writer, "IART", Artist);
                    len += WriteChunk(writer, "INAM", Name);
                    len += WriteChunk(writer, "IPRD", Product);
                    len += WriteChunk(writer, "IGNR", Genre);
                    len += WriteChunk(writer, "ICMT", Comment);
                    len += WriteChunk(writer, "ITRK", TrackNumber?.ToString());
                    len += WriteChunk(writer, "ICRD", CreationYear?.ToString());
                    len += WriteChunk(writer, "ISFT", Software);

                    if (len == 0)
                    {
                        // タグ情報なし : データを返さない
                        return(new byte[0]);
                    }

                    // INFO分を加算
                    len += sizeof(uint);

                    if (len % 2 != 0)
                    {
                        len++;
                        writer.Write((byte)0);
                    }

                    // サイズ部分を更新
                    stream.Seek(sizeof(uint), SeekOrigin.Begin);
                    writer.Write(len);


                    return(stream.ToArray());
                }
        }