Пример #1
0
    protected override float populateContainer(List <Item> items, RectTransform container)
    {
        float heightItem    = 100f;
        float posAcumulator = 0f;

        // change this according to the quantity of items or scene
        for (int i = 0; i < items.Count; i++)
        {
            RectTransform newItem = Instantiate(itemPreFab, container.transform.position, Quaternion.identity) as RectTransform;

            int newInt = i;

            ItemImages itemImage = items[newInt] as ItemImages;

            newItem.GetComponent <Image>().sprite = itemImage.getSprite;

            if (itemImage.Available)
            {
                Destroy(newItem.GetChild(0).gameObject);
                UnityAction clickAction = () => { callScene(itemImage); };
                newItem.GetComponentInChildren <Button>().onClick.AddListener(clickAction);
            }

            newItem.SetParent(container.transform);

            newItem.offsetMax = Vector2.zero;
            newItem.offsetMin = Vector2.zero;

            newItem.offsetMin = new Vector2(newItem.offsetMin.x, -posAcumulator);
            newItem.offsetMax = new Vector2(newItem.offsetMax.x, -posAcumulator);

            posAcumulator += heightItem;
        }
        return(posAcumulator);
    }
Пример #2
0
        public async Task <ActionResult <ItemImages> > PostItemImages(ItemImages itemImages)
        {
            _context.ItemImages.Add(itemImages);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetItemImages", new { id = itemImages.Id }, itemImages));
        }
Пример #3
0
        public async Task <IActionResult> PutItemImages(int id, ItemImages itemImages)
        {
            if (id != itemImages.Id)
            {
                return(BadRequest());
            }

            _context.Entry(itemImages).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ItemImagesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #4
0
        public ActionResult Edit(MissingItemViewModel Model)
        {
            if (ModelState.IsValid)
            {
                using (var context = new AmanatakContext())
                {
                    using (DbContextTransaction dbTran = context.Database.BeginTransaction())
                    {
                        try
                        {
                            //Save edit Item


                            Model.Item.ItemView     = true;
                            Model.Item.UserModified = "Operatort1";//For Prototype
                            Model.Item.DateModified = DateTime.UtcNow.AddHours(3);
                            Model.Item.ItemCategory = ItemCategory.Found;

                            db.Entry(Model.Item).State = EntityState.Modified;
                            db.SaveChanges();



                            //Save new Image
                            for (int i = 0; i < Model.ItemImages.Count; i++)
                            {
                                var file = Model.ItemImages[i];
                                if (file != null && file.ContentLength > 0)
                                {
                                    string FileName = Guid.NewGuid().ToString();
                                    file.SaveAs(Server.MapPath("~/ItemsImages/" + FileName + "-" + file.FileName));
                                    var itemImage = new ItemImages();


                                    itemImage.ImagePath = FileName + "-" + file.FileName;
                                    itemImage.ItemId    = Model.Item.Id;
                                    db.ItemImages.Add(itemImage);

                                    db.SaveChanges();
                                }
                            }
                            dbTran.Commit();
                            return(RedirectToAction("Index"));
                        }

                        catch (Exception ex)
                        {
                            dbTran.Rollback();
                        }
                    }
                }
            }



            ViewBag.ItemTypeId = new SelectList(db.ItemType, "Id", "Name", Model.Item.ItemTypeId);
            return(View(Model));
        }
Пример #5
0
        public override ADL_ItemImages MapItemImagestoDLItemImages(ItemImages itemimages)
        {
            var result = new MOCK_DL_ItemImages();

            result.ItemId  = itemimages.ItemId;
            result.ImageId = itemimages.ImageId;

            return(result);
        }
Пример #6
0
        public override ItemImages MapItemImagesfromDLItemImages(ADL_ItemImages itemimages)
        {
            var result = new ItemImages();

            result.ItemId  = itemimages.ItemId;
            result.ImageId = itemimages.ImageId;

            return(result);
        }
Пример #7
0
        //------------------------------------------------------------------------------------
        /// <summary>
        /// Reverts all changes in this item to the previously set values.
        /// </summary>
        //------------------------------------------------------------------------------------
        public void UndoChanges()
        {
            List <ItemProperty> changedProperties = m_changedProperties.ToList();

            foreach (ItemProperty itemProperty in changedProperties)
            {
                SetPublicProperty(itemProperty.PublicPropName, itemProperty.BackingValue);
            }

            ItemDocuments.UndoChanges();
            ItemImages.UndoChanges();
        }
 public void SeedItemImages()
 {
     ItemImages.Add(new ItemImage {
         ItemImageId = 1, Path = "knight_blue.png"
     });
     ItemImages.Add(new ItemImage {
         ItemImageId = 2, Path = "knight_red.png"
     });
     ItemImages.Add(new ItemImage {
         ItemImageId = 3, Path = "knight_green.png"
     });
     SaveChanges();
 }
Пример #9
0
    void callScene(ItemImages item)
    {
        user.CurrentTask = user.getTask(item.Name, user.CurrentCategory.Id);

        user.StartSavingTask();

        Application.LoadLevel(item.Name);

        GameObject persistenceTask = Resources.Load <GameObject> ("All_Task/prefab/TASK_RUNNING");

        Instantiate(persistenceTask);

        DBTimeControlTask.allowedToSave = false;

        Destroy(GameObject.FindGameObjectWithTag("MAIN_SCENE_OBJECT"));
    }
Пример #10
0
        public ItemImages Convert(ItemImageBO ii)
        {
            if (ii == null)
            {
                return(null);
            }
            ItemImages itemImage = new ItemImages
            {
                Id      = ii.Id,
                Image   = imc.Convert(ii.Image),
                ImageId = ii.ImageId,
                Item    = ic.Convert(ii.Item),
                ItemId  = ii.ItemId
            };

            return(itemImage);
        }
Пример #11
0
    protected override List <Item> populateList()
    {
        List <Task> tasks = user.TasksByCategory(user.CurrentCategory.Id);

        List <Item> items = new List <Item> ();


        foreach (Task task in tasks)
        {
            Item item = new ItemImages(
                task.Name,
                Resources.Load <Sprite> (resourceImageItem + task.Name),
                task.Available
                );
            items.Add(item);
        }

        return(items);
    }
Пример #12
0
        public ActionResult CreateItemMission(MissingItemViewModel input)
        {
            if (ModelState.IsValid)
            {
                using (var context = new AmanatakContext())
                {
                    using (DbContextTransaction dbTran = context.Database.BeginTransaction())
                    {
                        try
                        {
                            //Get Last Item Id

                            var LastId = 0;
                            var item   = db.Item.Select(e => e).FirstOrDefault();
                            if (item != null)
                            {
                                LastId = db.Item.OrderByDescending(p => p.Id).FirstOrDefault().Id;
                            }

                            //Save Item
                            input.Item.UserId       = 1;//For Prototype
                            input.Item.UserType     = UserType.Guest;
                            input.Item.ItemCategory = ItemCategory.Missing;

                            string number = String.Format("{0:d9}", (DateTime.Now.Ticks / 10) % 1000000000);
                            input.Item.SerialNumber = LastId.ToString() + number;
                            Session["SerialNumber"] = number;
                            input.Item.Deliveried   = false;
                            input.Item.ItemView     = false;
                            db.Item.Add(input.Item);
                            db.SaveChanges();
                            //Save Owner
                            input.ItemOwner.ItemId = input.Item.Id;
                            db.ItemOwner.Add(input.ItemOwner);
                            db.SaveChanges();

                            //Save Image
                            for (int i = 0; i < input.ItemImages.Count; i++)
                            {
                                var file = input.ItemImages[i];
                                if (file != null && file.ContentLength > 0)
                                {
                                    string FileName = Guid.NewGuid().ToString();
                                    file.SaveAs(Server.MapPath("~/ItemsImages/" + FileName + "-" + file.FileName));
                                    var itemImage = new ItemImages();


                                    itemImage.ImagePath = FileName + "-" + file.FileName;
                                    itemImage.ItemId    = input.Item.Id;
                                    db.ItemImages.Add(itemImage);

                                    db.SaveChanges();
                                }
                            }
                            dbTran.Commit();
                            ViewBag.ItemTypeId        = new SelectList(db.ItemType, "Id", "Name");
                            ViewBag.IdentificationID  = new SelectList(db.IdentificationType, "Id", "Name");
                            ViewBag.NationalityId     = new SelectList(db.Countries, "Id", "Name");
                            @TempData["SerialNumber"] = " <script>alert('تم تقديم الطلب برقم " + number + " ');</script>";
                            return(View());
                        }

                        catch (Exception ex)
                        {
                            dbTran.Rollback();
                        }
                    }
                }
            }
            ViewBag.IdentificationID = new SelectList(db.IdentificationType, "Id", "Name", input.ItemOwner.IdentificationID);
            ViewBag.NationalityId    = new SelectList(db.Countries, "Id", "Name", input.ItemOwner.Nationality);

            ViewBag.ItemTypeId = new SelectList(db.ItemType, "Id", "Name", input.Item.ItemTypeId);
            return(View(input));
        }
Пример #13
0
 public abstract ADL_ItemImages MapItemImagestoDLItemImages(ItemImages itemimages);