Ejemplo n.º 1
0
 public Extra addExtra(long employee, string Detail, long hours)
 {
     Extra result = null;
     try
     {
         using (var repository = new MainRepository(new AppContext("PostgresConnection")))
         {
             var extra = new ExtraEntity()
             {
                 employeeId = employee,
                 description = Detail,
                 hours = hours
             };
             extra = repository.Extras.Add(extra);
             var rows = repository.Complete();
             result = new Extra() { employee = extra.employeeId, detail = extra.description, hours = extra.hours, id = extra.id };
         }
     }
     catch (Exception e)
     {
         throw validateException(e);
     }
     return result;
 }
Ejemplo n.º 2
0
			public void Import(XmlElement node)
			{
				//string name = node.Name;
				string type = node.Attributes["type"].InnerText;

				switch (type)
				{
					case "Byte":
						Type = FieldType.Byte;
						break;

					case "Word":
						Type = FieldType.Word;
						break;

					case "Dword":
						Type = FieldType.Dword;
						break;

					case "StringId":
						Type = FieldType.StringId;
						break;

					case "Block":
						Type = FieldType.Block;
						_Extra = new Extra();
						_Extra._Block = new Block();
						_Extra._Block.Import(node["block"]);
						break;

					case "TagReference":
						Type = FieldType.Reference;
						break;

					case "Data":
						Type = FieldType.Data;
						break;

					case "GeometryBlock":
						in_geometry_block = true;
						Type = FieldType.GeometryBlock;
						break;

					case "AnimationCache":
						Type = FieldType.AnimationCache;
						break;

					case "BitmapCache":
						Type = FieldType.BitmapCache;
						break;

					case "SoundCache":
						Type = FieldType.SoundCache;
						break;

					case "Struct":
						Type = FieldType.Struct;
						_Extra = new Extra();
						_Extra.Name = node.Attributes["name"].InnerText;
						_Extra.Size = Convert.ToInt32(node.Attributes["size"].InnerText);
						_Extra.Tag = node.Attributes["definition"].InnerText.ToCharArray();
						break;

					case "StructEnd":
						in_geometry_block = false;
						Type = FieldType.None;
						break;

					case "ArrayStart":
						Type = FieldType.None;
						break;

					case "ArrayEnd":
						Type = FieldType.None;
						break;
				}

				if(Type == FieldType.Byte ||
					Type == FieldType.Word ||
					Type == FieldType.Dword)
				{
					if(node.Attributes["definition"] != null)
						(_Extra = new Extra()).Size = Convert.ToInt32(node.Attributes["definition"].InnerText);
				}

				if (Type != FieldType.None)
				{
					Offset = Convert.ToInt32(node.Attributes["offsetFile"].InnerText);
					OffsetCache = Convert.ToInt32(node.Attributes["offsetCache"].InnerText);
					OffsetAlpha = Convert.ToInt32(node.Attributes["offsetAlphaFile"].InnerText);
					OffsetAlphaCache = Convert.ToInt32(node.Attributes["offsetAlphaCache"].InnerText);
				}
			}
Ejemplo n.º 3
0
 public Extra selectExtra(long idExtra)
 {
     Extra result = null;
     try
     {
         using (var repository = new MainRepository(new AppContext("PostgresConnection")))
         {
             var extra = repository.Extras.Get(idExtra);
             if (extra != null)
             {
                 result = new Extra()
                 {
                     hours = extra.hours,
                     detail = extra.description,
                     employee = extra.employeeId,
                     id = extra.id
                 };
             }
             else
             {
                 throw validateException(App_LocalResoures.Errors.inexistentExtra);
             }
         }
     }
     catch (Exception e)
     {
         throw validateException(e);
     }
     return result;
 }
 public void UpdateExtra(Extra e)
 {
     repoExtra.Update(e);
     repoExtra.SaveChanges();
 }
 public Extra InsertExtra(Extra e)
 {
     Extra result = repoExtra.Insert(e);
     repoExtra.SaveChanges();
     return result;
 }
 public ActionResult New3(Extra e)
 {
     if (ModelState.IsValid)
     {
         afs.InsertExtra(e);
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
 }
 public ActionResult Edit3(Extra e)
 {
     if (ModelState.IsValid)
     {
         afs.UpdateExtra(e);
         return RedirectToAction("Index");
     }
     else
     {
         return View();
     }
 }