public async Task <IActionResult> Edit(int id, [Bind("Id,ZipCode,BusinessName,ApplicationUserId")] ShopOwner shopOwner)
        {
            if (id != shopOwner.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(shopOwner);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ShopOwnerExists(shopOwner.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", shopOwner.ApplicationUserId);
            return(View(shopOwner));
        }
Exemplo n.º 2
0
        public void AddShopOwner(Shop shop, Guid userGuid, Guid newOwnerGuid, string appointerUsername)
        {
            int signatures_required = shop.Owners.Count() + 1;     //+1 For Creator

            if (shop.candidate == null && signatures_required > 1) // a new candidate
            {
                var newCandidate = new OwnerCandidate(newOwnerGuid, shop.Guid, userGuid, signatures_required, appointerUsername);
                shop.candidate = newCandidate;
            }
            else if (shop.candidate != null) // there is a candidate, sign it if possible
            {
                var candidate = shop.candidate;
                if (candidate.signature_target - candidate.Signatures.Count() == 1) // last sign , promote the candidate to a shop owner
                {
                    var newOwner = new ShopOwner(newOwnerGuid, candidate.AppointerGuid, shop.Guid);
                    shop.Owners.Add(newOwner);
                    shop.candidate = null;
                }
                else if (!candidate.Signatures.Values.Contains(userGuid)) //if not already signed , sign the candidate
                {
                    candidate.Signatures.Add(appointerUsername, userGuid);
                }
            }
            else// in the case: adding the second shopowner
            {
                var newOwner = new ShopOwner(newOwnerGuid, userGuid, shop.Guid);
                shop.Owners.Add(newOwner);
            }

            _unitOfWork.ShopRepository.Update(shop);
        }
Exemplo n.º 3
0
        public ActionResult Registeration(Registration obj)
        {
            try
            {
                ShopOwner    s  = new ShopOwner();
                MedicalStore Ms = new MedicalStore();
                Ms.ShopName    = obj.ShopName;
                Ms.ShopAddress = obj.ShopAddress;
                db.MedicalStores.Add(Ms);

                db.SaveChanges();
                s.Name             = obj.Name;
                s.CNIC             = obj.CNIC;
                s.Confirm_Password = obj.Confirm_Password;
                s.Email            = obj.Email;
                s.ShopId           = Ms.ShopId;
                s.OwnerId          = Ms.ShopId;
                db.ShopOwners.Add(s);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Exemplo n.º 4
0
        public bool AddOwner(Shop shop, Guid appointerGuid, Guid newOwnerGuid)
        {
            var result = false;
            int signatures_required = shop.Owners.Count() + 1;     //+1 for the shop creator

            if (shop.candidate == null && signatures_required > 1) // a new candidate
            {
                var newCandidate = new OwnerCandidate(newOwnerGuid, shop.Guid, appointerGuid, signatures_required, _unitOfWork.BaseUserRepository.GetUsername(appointerGuid));
                shop.candidate = newCandidate;
            }
            else if (shop.candidate != null) // there is a candidate, sign it if possible
            {
                var candidate = shop.candidate;
                if (candidate.signature_target - candidate.Signatures.Count() == 1) // last sign , promote the candidate to a shop owner
                {
                    var newOwner = new ShopOwner(newOwnerGuid, candidate.AppointerGuid, shop.Guid);
                    shop.Owners.Add(newOwner);
                    shop.candidate = null;
                }
                else if (!candidate.Signatures.Values.Contains(appointerGuid)) //if not already signed , sign the candidate
                {
                    candidate.Signatures.Add(_unitOfWork.BaseUserRepository.GetUsername(appointerGuid), appointerGuid);
                }
            }
            else// in the case: adding the second shopowner
            {
                var newOwner = new ShopOwner(newOwnerGuid, appointerGuid, shop.Guid);
                shop.Owners.Add(newOwner);
            }
            result = true;
            _unitOfWork.ShopRepository.Update(shop);
            return(result);
        }
Exemplo n.º 5
0
        public void AddShopManager(Shop shop, Guid userGuid, Guid newManagaerGuid, List <bool> priviliges)
        {
            var newManager = new ShopOwner(newManagaerGuid, userGuid, shop.Guid, priviliges);

            shop.AddShopManager(newManager);
            _unitOfWork.ShopRepository.Update(shop);
        }
Exemplo n.º 6
0
        public ShopOwner getShopOwner(int ownerId)
        {
            ShopOwner shopOwner = null;

            string query = "SELECT * FROM shopowner WHERE Id = @Id";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                command.Connection.Open();
                command.Parameters.AddWithValue("@Id", ownerId);
                command.CommandType = System.Data.CommandType.Text;

                using (MySqlDataReader reader = command.ExecuteReader())
                {
                    if (reader.HasRows)
                    {
                        if (reader.Read())
                        {
                            shopOwner = new ShopOwner(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetDateTime(5), reader.GetString(6), reader.GetBoolean(7));
                        }
                    }
                    reader.Close();
                }
                //Close Connection
                command.Connection.Close();
            }

            return(shopOwner);
        }
Exemplo n.º 7
0
        public static World Generate()
        {
            //var building = new Building("Farm house");
            Debug.Log("Generating Test world");
            var       world   = new World();
            var       area    = new Area("Farm area");
            Farmer    person  = GenerateFarm(area, 20, 20, "Jim");
            Farmer    person1 = GenerateFarm(area, 120, 150, "John");
            Farmer    person2 = GenerateFarm(area, -120, -120, "Wim");
            Farmer    person3 = GenerateFarm(area, -130, 100, "Eddard");
            Farmer    person4 = GenerateFarm(area, 130, -90, "John");
            ShopOwner person5 = GenerateShop(area, 0, -160, "Mark");
            Miller    person6 = GenerateMill(area, 0, 160, "Mark");
            Baker     person7 = GenerateBakery(area, -40, 160, "Mark");

            GenerateWell(area, 60, 175);
            world.AddPerson(person);
            world.AddPerson(person1);
            world.AddPerson(person2);
            world.AddPerson(person3);
            world.AddPerson(person4);
            world.AddPerson(person5);
            world.AddPerson(person6);
            world.AddPerson(person7);


            //for(int i = 0; i < 10000; i++)
            //{
            //    Farmer personx = GenerateFarm(area, 20+i*100, 20, "Jim");
            //    world.AddPerson(personx);
            //}
            world.AddArea(area);

            return(world);
        }
Exemplo n.º 8
0
        public bool updateShopOwner(ShopOwner owner)
        {
            bool success = false;

            query = @"UPDATE shopowner SET  Email = @Email, FullName = @FullName, Number = @Number WHERE Id = @Id";

            using (MySqlCommand command = new MySqlCommand(query, new MySqlConnection(getConnectionString())))
            {
                //General
                command.Parameters.AddWithValue("@Id", owner.Id);
                command.Parameters.AddWithValue("@Email", owner.Email);
                command.Parameters.AddWithValue("@FullName", owner.FullName);
                command.Parameters.AddWithValue("@Number", owner.Number);

                command.Connection.Open();

                command.CommandType = System.Data.CommandType.Text;
                command.ExecuteNonQuery();

                command.Connection.Close();

                success = true;
            }

            return(success);
        }
Exemplo n.º 9
0
        public static string RegisterShopManager(string FN, string LN, DateTime dob, int age, string G, string contact, string admId, string admPsw, string confPsw)
        {
            string message = string.Empty;

            try
            {
                if (!admPsw.Equals(confPsw))
                {
                    message = "Confirm Password Not Matched !!";
                }
                else
                {
                    if (ValidateContactNo(contact) == true)
                    {
                        int r = ShopOwner.RegisterShopOwnerDetails(DBConnector.GetDBConnection(), FN, LN, dob, age, G, contact, admId, admPsw);
                        if (r > 0)
                        {
                            message = "ShopManager Details Registered Successfully!";
                        }
                        else
                        {
                            message = "Registration Failure!";
                        }
                    }
                    else
                    {
                        message = "Invalid Contact No";
                    }
                }
            }
            catch (Exception ex) { message = ex.Message; }
            return(message);
        }
Exemplo n.º 10
0
 public static void VerifyOwner(ShopOwner expected, ShopOwner actual)
 {
     Assert.AreEqual(expected.OwnerGuid, actual.OwnerGuid);
     Assert.AreEqual(expected.AppointerGuid, actual.AppointerGuid);
     Assert.AreEqual(expected.ShopGuid, actual.ShopGuid);
     CollectionAssert.AreEquivalent(expected.Privileges, actual.Privileges);
 }
        public async Task <IActionResult> Create([Bind("Id,Address,City,State,ZipCode,BusinessName,ApplicationUserId")] ShopOwner shopOwner)
        {
            if (ModelState.IsValid)
            {
                var userId = this.User.FindFirstValue(ClaimTypes.NameIdentifier);
                shopOwner.ApplicationUserId = userId;
                var addressString     = $"{shopOwner.Address}+{shopOwner.City}+{shopOwner.State}+{shopOwner.ZipCode}";
                var url               = $"https://maps.googleapis.com/maps/api/geocode/json?address={addressString}&key={APIKey.SecretKey}";
                var jsonObject        = new WebClient().DownloadString(url);
                var shopOwnerLocation = JsonConvert.DeserializeObject <RootObject>(jsonObject);

                shopOwner.Latitude  = shopOwnerLocation.results[0].geometry.location.lat;
                shopOwner.Longitude = shopOwnerLocation.results[0].geometry.location.lng;
                Dictionary <string, double> latLng = new Dictionary <string, double>()
                {
                    { "lat", shopOwner.Latitude }, { "lng", shopOwner.Longitude }
                };
                shopOwner.LatLng = latLng;
                _context.Add(shopOwner);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Create", "ShopHashtags"));
            }
            ViewData["ApplicationUserId"] = new SelectList(_context.ApplicationUsers, "Id", "Id", shopOwner.ApplicationUserId);
            return(View(shopOwner));
        }
Exemplo n.º 12
0
        public Boolean Post([FromBody] ShopOwner shopowner)
        {
            if (_ShopOwnerDataProvider.RegisterShopOwner(shopowner))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 13
0
        public static Shop SaveShopOwner()
        {
            var shop = SaveShopWithName();

            var owner = new ShopOwner(Guid.NewGuid(), shop.Guid);

            shop.AddShopOwner(owner);

            return(shop);
        }
Exemplo n.º 14
0
        private static ShopOwner GenerateShop(Area area, int x, int y, string name)
        {
            var shop   = new Shop(Guid.NewGuid(), "Shop", area, x, y, 20, 20);
            var person = new ShopOwner(Guid.NewGuid(), name, shop);

            shop.Owner = person;

            person.AddOwnerShip(shop);
            shop.Inventory.AddResource(new WheatSeed(), 10000);
            area.AddLocation(shop);

            return(person);
        }
Exemplo n.º 15
0
        public static Shop SaveShopManager()
        {
            var shop = SaveShopWithName();

            var manager = new ShopOwner(Guid.NewGuid(), shop.Guid, new List <bool>()
            {
                true, false, false, false
            });

            shop.AddShopManager(manager);

            return(shop);
        }
        public IActionResult Post([FromBody] ShopOwner shopowner)
        {
            result = _ShopOwnerDataProvider.RegisterShopOwner(shopowner);
            if (result == null)
            {
                return(new BadRequestResult());
            }


            String Token = BuildToken(result);

            return(new OkObjectResult(new { token = Token }));
        }
Exemplo n.º 17
0
        public UserModel RegisterShopOwner(ShopOwner shopowner)
        {
            var email = shopowner.Email;

            shopowner.Pass_word = HashAndSalt.HashSalt(shopowner.Pass_word);
            using (IDbConnection dbConnection = Connection)
            {
                string sQuery0 = "SELECT FirstName FROM ShopOwner WHERE Email = @email";
                dbConnection.Open();
                String result = dbConnection.QueryFirstOrDefault <String>(sQuery0, new { @Email = email });
                dbConnection.Close();

                if (string.IsNullOrEmpty(result))
                {
                    String VerifiCode = VerifiCodeGenarator.CreateRandomPassword();
                    shopowner.VerifiCode = VerifiCode;
                    shopowner.Validated  = false;
                    string sQuery = "INSERT INTO ShopOwner(FirstName,LastName,Pass_word,Email,MobileNo,VerifiCode,Validated)" +
                                    "VALUES(@FirstName,@LastName,@Pass_word,@Email,@MobileNo,@VerifiCode,@Validated)";

                    dbConnection.Open();
                    dbConnection.Execute(sQuery, shopowner);
                    dbConnection.Close();

                    SendMail(email, VerifiCode);

                    string sQuery1 = "SELECT ShopOwnerId from ShopOwner where Email = @email";
                    string ID      = dbConnection.QueryFirstOrDefault <String>(sQuery1, new { @Email = email });

                    UserModel user = null;
                    user = new UserModel {
                        Id = ID, Name = shopowner.FirstName, Email = shopowner.Email
                    };
                    //String Token = BuildToken(user);
                    //return new OkObjectResult(new { token = Token });
                    return(user);
                }

                return(null);
            }

            /* var method = typeof(TokenCreator).GetMethod("createToken");
             * var action = (Action<TokenCreator>)Delegate.CreateDelegate(typeof(Action<TokenCreator>), method);
             * action(user);*/

            //TokenCreator tokencreator = new TokenCreatorC();
            //return tokencreator.createToken(user);
        }
Exemplo n.º 18
0
        protected void btnFinish_Click(object sender, EventArgs e)
        {
            /*Start by Adding special to the database ***/
            if (txtDescription.Text.Equals("") || txtOpenHours.Equals("") || txtShoNo.Equals("") || txtShopName.Equals("") || txtText.Equals(""))
            {
                lblErrorMessage.Text = "All fields are required";
                return;
            }

            ShopOwner owner        = (ShopOwner)Session["SHOPOWNER"];
            bool      uploadStatus = true;
            string    filename1    = "defaultProfilePic.jpg";

            //Check if the files have something
            if (fu1.HasFile)
            {
                try
                {
                    filename1 = Path.GetFileName(fu1.FileName);
                    fu1.SaveAs(Server.MapPath("~/Images/Shops/") + filename1);
                }
                catch (Exception ex)
                {
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                    uploadStatus         = false;
                }
            }

            if (uploadStatus)
            {
                string images = filename1;

                //Upload shop
                if (new ShopConnection().postShop(new Models.ShopOwnerModel.Shop(owner.Id, "", txtDescription.Text, images, txtShopName.Text, txtOpenHours.Text, Convert.ToInt32(txtShoNo.Text), txtText.Text)))
                {
                    lblSuccess.Text = "You have successfully added a Special";
                    Response.Redirect("ManageListings.aspx");
                }
                else
                {
                    lblErrorMessage.Text = "Sorry an error occured while listing your Special, please try again";
                }
            }
            else
            {
                lblErrorMessage.Text = "Sorry an error occured while listing your Special, please upload image again";
            }
        }
Exemplo n.º 19
0
        public bool HasItem(IWIBase item, out WIStack stack)
        {
            stack = null;
            if (mContainerEnabler == null)
            {
                return(false);
            }
            if (!mContainerEnabler.HasEnablerStack)
            {
                return(false);
            }
            WIStack        nextStack     = null;
            List <WIStack> enablerStacks = mContainerEnabler.EnablerStacks;

            for (int i = 0; i < enablerStacks.Count; i++)
            {
                nextStack = enablerStacks [i];
                if (nextStack.Items.Contains(item))
                {
                    stack = nextStack;
                    break;
                }
            }

            if (stack == null)
            {
                ShopOwner shopOwner = null;
                if (worlditem.Is <ShopOwner> (out shopOwner))
                {
                    //are we alive? if so, this can mean any containers that are owned by us in the group
                    //start in the group that
                    List <Container> containers = new List <Container> ();
                    if (WIGroups.GetAllContainers(worlditem.Group, containers))
                    {
                        foreach (Container container in containers)
                        {
                            if (Stacks.Find.Item(container.worlditem.StackContainer, item, out stack))
                            {
                                Debug.Log("Found item in shop owner container");
                                break;
                            }
                        }
                    }
                }
            }

            return(stack != null);
        }
Exemplo n.º 20
0
        protected void btnFinish_Click(object sender, EventArgs e)
        {
            ShopOwner owner = (ShopOwner)Session["SHOPOWNER"];

            if (txtDescription.Text == string.Empty || txtName.Text == string.Empty || txtOpenHours.Text == string.Empty ||
                txtPrice.Text == string.Empty || txtShoNo.Text == string.Empty || txtShopName.Text == string.Empty ||
                txtText.Text == string.Empty)
            {
                divError.Visible = true;
            }
            else
            {
                divError.Visible = false;
            }

            string filename1 = file;

            //Check if the files have something
            if (fu1.HasFile)
            {
                try
                {
                    filename1 = owner.Id + Path.GetFileName(fu1.FileName);
                    fu1.SaveAs(Server.MapPath("~/Images/Shops/Specials/") + filename1);
                }
                catch (Exception ex)
                {
                    divError.Visible = true;
                    return;
                }
            }


            Qaelo.Models.ShopOwnerModel.Shop special = new Qaelo.Models.ShopOwnerModel.Shop(Convert.ToInt32(Request.QueryString["editId"].ToString()), owner.Id, txtPrice.Text, txtDescription.Text, filename1, txtName.Text, txtOpenHours.Text, Convert.ToInt32(txtShoNo.Text)
                                                                                            , txtText.Text);

            if (new ShopConnection().updateSpecial(special, owner.Id))
            {
                Response.Redirect("ManageListings.aspx?page=specials");
            }
            else
            {
                divError.InnerHtml = "<p>An error occured while saving your special please try agian.</p>";
            }
        }
Exemplo n.º 21
0
        protected void btnFinish_Click(object sender, EventArgs e)
        {
            ShopOwner owner        = (ShopOwner)Session["SHOPOWNER"];
            bool      uploadStatus = true;
            string    filename1    = "";
            int       shopId       = Convert.ToInt32(Request.QueryString["editId"]);

            //Check if the files have something
            if (fu1.HasFile)
            {
                try
                {
                    filename1 = Path.GetFileName(fu1.FileName);
                    fu1.SaveAs(Server.MapPath("~/Images/Shops/") + filename1);
                }
                catch (Exception ex)
                {
                    lblErrorMessage.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                    uploadStatus         = false;
                }
            }
            else
            {
                filename1 = new ShopConnection().getShopById(shopId).Image;
            }

            if (uploadStatus)
            {
                //Upload shop
                if (new ShopConnection().updateShop(new Models.ShopOwnerModel.Shop(shopId, owner.Id, "", txtDescription.Text, filename1, txtShopName.Text, txtOpenHours.Text, Convert.ToInt32(txtShoNo.Text), txtText.Text), owner.Id))
                {
                    lblSuccess.Text = "You have successfully Edit " + txtShopName.Text + " a Special";
                    Response.Redirect("ManageListings.aspx");
                }
                else
                {
                    lblErrorMessage.Text = "Sorry an error occured while listing your Special, please try again";
                }
            }
            else
            {
                lblErrorMessage.Text = "Sorry an error occured while listing your Special, please upload image again";
            }
        }
        public override IHuman GetHuman(HumanType humanType)
        {
            switch (humanType)
            {
            case HumanType.Beggar:
                IHuman beggar = new Beggar();
                return(beggar);

            case HumanType.Farmer:
                IHuman farmer = new Farmer();
                return(farmer);

            case HumanType.ShopOwner:
                IHuman shopOwner = new ShopOwner();
                return(shopOwner);
            }

            return(null);
        }
        public void AuthenticateShopOwner_ShopOwnerNotFoundInRepository_ReturnsNull()
        {
            // prepare
            string    nonExistingUserEmail = "*****@*****.**";
            string    validPassword        = "******";
            ShopOwner shopOwner            = null;

            var shopOwnerRepositoryMock = _kernel.GetMock <IMembershipRepository>();

            shopOwnerRepositoryMock.Setup(x => x.Get(nonExistingUserEmail)).Returns(shopOwner);

            var repositoryFactoryMock = _kernel.GetMock <IMembershipRepositoryFactory>();

            repositoryFactoryMock.Setup(x => x.CreateMembershipRepository(UserTypeOptions.ShopOwner)).Returns(shopOwnerRepositoryMock.Object);
            IAuthenticator authenticator = _kernel.Get <IAuthenticator>();

            // act
            IAuthenticationToken token = authenticator.AuthenticateShopOwner(nonExistingUserEmail, validPassword);

            // assert
            Assert.IsNull(token);
        }
Exemplo n.º 24
0
    public INPC getNPC(NPCType type)
    {
        switch (type)
        {
        case NPCType.Beggar:
            INPC beggar = new Beggar();
            return(beggar);

        case NPCType.Farmer:
            INPC farmer = new Farmer();
            return(farmer);

        case NPCType.Shopowner:
            INPC shopowner = new ShopOwner();
            return(shopowner);

        case NPCType.QuestGiver:
            INPC questgiver = new QuestGiver();
            return(questgiver);
        }
        return(null);
    }
Exemplo n.º 25
0
        public ActionResult OwnerProfile(int?id)
        {
            Registration obj = new Registration();
            ShopOwner    s   = db.ShopOwners.Find(id);

            if (s == null)
            {
                return(HttpNotFound());
            }
            else
            {
                obj.Name             = s.Name;
                obj.CNIC             = s.CNIC;
                obj.Email            = s.Email;
                obj.ShopId           = s.ShopId;
                obj.Confirm_Password = s.Confirm_Password;
                MedicalStore Ms = db.MedicalStores.Find(obj.ShopId);
                obj.ShopName    = Ms.ShopName;
                obj.ShopAddress = Ms.ShopAddress;
                obj.OwnerId     = s.OwnerId;
            }
            return(View(obj));
        }
        public bool RegisterShopOwner(ShopOwner shopowner)
        {
            var email = shopowner.Email;

            shopowner.Pass_word = HashAndSalt.HashSalt(shopowner.Pass_word);
            using (IDbConnection dbConnection = Connection)
            {
                string sQuery0 = "SELECT FirstName FROM ShopOwner WHERE Email = @email";
                dbConnection.Open();
                String result = dbConnection.QueryFirstOrDefault <String>(sQuery0, new { @Email = email });
                dbConnection.Close();

                if (string.IsNullOrEmpty(result))
                {
                    string sQuery = "INSERT INTO ShopOwner(FirstName,LastName,Pass_word,Email,MobileNo)" +
                                    "VALUES(@FirstName,@LastName,@Pass_word,@Email,@MobileNo)";

                    dbConnection.Open();
                    dbConnection.Execute(sQuery, shopowner);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 27
0
        public IEnumerator GetInventoryContainer(int currentIndex, bool forward, GetInventoryContainerResult result)
        {
            if (result == null)
            {
                yield break;
            }

            mOnAccessInventory.SafeInvoke();

            if (mContainerEnabler == null)
            {
                //if we don't have an enabler, we need one now
                if (CharacterInventoryGroup == null)
                {
                    //if we don't have a character group, we'll need to create it to store our stuff
                    CharacterInventoryGroup = WIGroups.GetOrAdd(worlditem.FileName, WIGroups.Get.World, worlditem);
                }
                //make sure the group is loaded
                CharacterInventoryGroup.Load();
                //create a new container enabler for our stuff
                mContainerEnabler = Stacks.Create.StackEnabler(CharacterInventoryGroup);
            }

            int       totalContainers = 1;
            ShopOwner shopOwner       = null;

            if (worlditem.Is <ShopOwner> (out shopOwner))
            {
                //are we alive? if so, this can mean any containers that are owned by us in the group
                //start in the group that
                int nextIndex = currentIndex;
                List <Container> containers = new List <Container> ();
                if (WIGroups.GetAllContainers(worlditem.Group, containers))
                {
                    if (forward)
                    {
                        nextIndex = containers.NextIndex <Container> (currentIndex);
                    }
                    else
                    {
                        nextIndex = containers.PrevIndex <Container> (currentIndex);
                    }
                    //tell the container that we're opening it, then wait a tick for it to fill
                    try {
                        containers [nextIndex].OnOpenContainer();
                    } catch (Exception e) {
                        Debug.LogException(e);
                        yield break;
                    }
                    yield return(null);

                    mContainerEnabler.EnablerStack.Items.Clear();
                    Stacks.Display.ItemInEnabler(containers [nextIndex].worlditem, mContainerEnabler);
                    result.ContainerEnabler = mContainerEnabler;
                    result.ContainerIndex   = nextIndex;
                    result.TotalContainers  = containers.Count;
                }
            }
            else
            {
                //if we're not a shop owner
                //then there's exactly one container, our inventory container
                //if we're holding a temporary item then there are two
                if (IsHoldingTemporaryItem)
                {
                    Debug.Log("We're holding item so we'll return 2 containers");
                    //index 0 is our container enabler
                    //index 1 is our temporary item
                    result.TotalContainers = 2;
                    if (currentIndex == 0)                      //toggle to our held item
                    //Stacks.Display.ItemInEnabler (worlditem, mTemporaryItemEnabler);
                    {
                        result.ContainerIndex   = 1;
                        result.ContainerEnabler = mTemporaryItemEnabler;
                    }
                    else                        //toggle to our container enabler
                    {
                        Stacks.Display.ItemInEnabler(worlditem, mContainerEnabler);
                        result.ContainerIndex   = 0;
                        result.ContainerEnabler = mContainerEnabler;
                    }
                }
                else
                {
                    Stacks.Display.ItemInEnabler(worlditem, mContainerEnabler);
                    result.ContainerIndex   = 0;
                    result.TotalContainers  = 1;
                    result.ContainerEnabler = mContainerEnabler;
                }
                //this is always the same
                result.InventoryBank = InventoryBank;
            }
            yield break;
        }
Exemplo n.º 28
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["SHOPOWNER"] == null)
            {
                Response.Redirect("~/Web/Account/tempLogin.aspx?page=Users/Shop/ManageListings.aspx");
            }
            //Load manager
            ShopOwner owner = (ShopOwner)Session["SHOPOWNER"];

            Data.ShopData.ShopConnection connection = new Data.ShopData.ShopConnection();

            if (Request.QueryString["delId"] != null)
            {
                if (connection.deleteshop(Convert.ToInt32(Request.QueryString["delId"].ToString()), owner.Id))
                {
                    lblSuccess.Text = "Shop has been deleted successfuly";
                }
                else
                {
                    lblErrorMessage.Text = "An error occurred while deleting, shop please try again";
                }
            }

            if (Request.QueryString["delSpecialId"] != null)
            {
                if (connection.deleteSpecial(Convert.ToInt32(Request.QueryString["delSpecialId"].ToString()), owner.Id))
                {
                    lblSuccess.Text = "Special has been deleted successfuly";
                }
                else
                {
                    lblErrorMessage.Text = "An error occurred while deleting special, please try again";
                }
            }

            if (Request.QueryString["page"] != null)
            {
                if (Request.QueryString["page"].Equals("specials"))
                {
                    lblSuccess.Text = "Special has been added successfuly";
                }
            }
            //Load Shops
            List <Qaelo.Models.ShopOwnerModel.Shop> shops = connection.getAllMyShops(owner.Id);
            string html = "";

            foreach (Qaelo.Models.ShopOwnerModel.Shop shop in shops)
            {
                html += string.Format(@"<div class='col-sm-3'>
                <div class='thumbnail'>
                  <div class='w3-card-12'>
                      <figure >
                      <img src='../../../Images/Shops/{0}' class='' style='height:220px;width:100%'/>
                          <figcaption style = 'background-image: url('')'>
                               </figcaption>
                           </figure>
                    <div class='w3-container' style='margin:10px'>
                        <h6><b>{2} - <small>{3}</small></b></h6>
                        <strong>Shop No:<small>{4}</small></strong><br />
                       <strong> Open: <small>{5}</small></strong><br />
                        <strong>Call:<small>{6}</small>
                        </strong><br /><br />
                            <a href='ManageListings.aspx?delId={7}' class='btn btn-danger pull-lef'>Delete</a>
                            <a href='EditShop.aspx?editId={7}' class='btn btn-info pull-right'>Edit</a>
                    </div>
                  </div>
                </div>
            </div>", shop.Image, shop.Description, shop.Name, shop.University, shop.ShopNo, shop.TradingHours, owner.Number, shop.Id);
            }

            lblShops.Text = html;

            /**List Of Specials **/
            List <Qaelo.Models.ShopOwnerModel.ShopAds> specials = connection.getAllSpecialsByManagerId(owner.Id);
            string htmlSpecials = "";

            foreach (Qaelo.Models.ShopOwnerModel.ShopAds shop in specials)
            {
                htmlSpecials += string.Format(@"<div class='col-sm-3'>
                <div class='thumbnail'>
                  <div class='w3-card-12'>
                      <figure >
                      <img src='../../../Images/Shops/Specials/{0}' class='' style='height:220px;width:100%'/>
                          <figcaption style = 'background-image: url('')'>
                               </figcaption>
                           </figure>
                    <div class='w3-container' style='margin:10px'>
                        <h6><b>{2} - <small>{3}</small></b></h6>
                        <strong>Shop No:<small>{4}</small></strong><br />
                       <strong> Open: <small>{5}</small></strong><br />
                        <strong>Call:<small>{6}</small>
                        </strong><br /><br />
                            <a href='ManageListings.aspx?delSpecialId={7}' class='btn btn-danger pull-lef'>Delete</a>
                            <a href='EditSpecial.aspx?editId={7}' class='btn btn-info pull-right'>Edit now</a>
                    </div>
                  </div>
                </div>
            </div>", shop.Image, shop.Description, shop.Name, shop.University, shop.ShopNo, shop.TradingHours, owner.Number, shop.Id);
            }

            lblSpecials.Text = htmlSpecials;
        }
Exemplo n.º 29
0
        protected void btnFinish_Click(object sender, EventArgs e)
        {
            ShopOwner owner = (ShopOwner)Session["SHOPOWNER"];

            if (txtDescription.Text == string.Empty || txtName.Text == string.Empty || txtOpenHours.Text == string.Empty ||
                txtPrice.Text == string.Empty || txtShoNo.Text == string.Empty || txtShopName.Text == string.Empty ||
                txtText.Text == string.Empty)
            {
                divError.Visible = true;
                return;
            }
            else
            {
                divError.Visible = false;
            }
            string filename1 = "defaultProfilePic.jpg";

            //Check if the files have something
            if (fu1.HasFile)
            {
                try
                {
                    filename1 = owner.Id + Path.GetFileName(fu1.FileName);
                    fu1.SaveAs(Server.MapPath("~/Images/Shops/Specials/") + filename1);
                }
                catch (Exception ex)
                {
                    divError.Visible = true;
                    return;
                }
            }


            Qaelo.Models.ShopOwnerModel.Shop special = new Qaelo.Models.ShopOwnerModel.Shop(owner.Id, txtPrice.Text, txtDescription.Text, filename1, txtName.Text, txtOpenHours.Text, Convert.ToInt32(txtShoNo.Text)
                                                                                            , txtText.Text);

            if (new ShopConnection().postSpecial(special))
            {
                Response.Redirect("ManageListings.aspx?page=specials");
            }
            else
            {
                divError.InnerHtml = "<p>An error occured while saving your special please try agian.</p>";
            }
            //try
            //{
            //    if (!Page.IsValid) return;

            //    // Create the order in your DB and get the ID
            //    string amount = "";
            //    string orderId = "";

            //    if( adR70.Checked)
            //    {
            //        amount = "70";
            //    }
            //    else if(adR100.Checked)
            //    {
            //        amount = "100";
            //    }
            //    else if(adR300.Checked)
            //    {
            //        amount = "300";
            //    }

            //    string name = "Qaelo, Shop advert order" + orderId;

            //    string description = "Advert Payment, Order #" + orderId;

            //    string site = "";
            //    string merchant_id = "";
            //    string merchant_key = "";

            //    // Check if we are using the test or live system
            //    string paymentMode = System.Configuration.ConfigurationManager.AppSettings["PaymentMode"];

            //    if (paymentMode == "test")
            //    {
            //        site = "https://sandbox.payfast.co.za/eng/process?";
            //        merchant_id = "10000100";
            //        merchant_key = "46f0cd694581a";
            //    }
            //    else if (paymentMode == "live")
            //    {
            //        site = "https://www.payfast.co.za/eng/process?";
            //        merchant_id = System.Configuration.ConfigurationManager.AppSettings["PF_MerchantID"];
            //        merchant_key = System.Configuration.ConfigurationManager.AppSettings["PF_MerchantKey"];
            //    }
            //    else
            //    {
            //        throw new InvalidOperationException("Cannot process payment if PaymentMode (in web.config) value is unknown.");
            //    }

            //    // Build the query string for payment site

            //    System.Text.StringBuilder str = new System.Text.StringBuilder();
            //    str.Append("merchant_id=" + HttpUtility.UrlEncode(merchant_id));
            //    str.Append("&merchant_key=" + HttpUtility.UrlEncode(merchant_key));
            //    str.Append("&return_url=" + HttpUtility.UrlEncode(System.Configuration.ConfigurationManager.AppSettings["PF_ReturnURL"]));
            //    str.Append("&cancel_url=" + HttpUtility.UrlEncode(System.Configuration.ConfigurationManager.AppSettings["PF_CancelURL"]));
            //    str.Append("&notify_url=" + HttpUtility.UrlEncode(System.Configuration.ConfigurationManager.AppSettings["PF_NotifyURL"]));

            //    str.Append("&m_payment_id=" + HttpUtility.UrlEncode(orderId));
            //    str.Append("&amount=" + HttpUtility.UrlEncode(amount));
            //    str.Append("&item_name=" + HttpUtility.UrlEncode(name));
            //    str.Append("&item_description=" + HttpUtility.UrlEncode(description));

            //    //Default email


            //    // Redirect to PayFast
            //    Response.Redirect(site + str.ToString());
            //}
            //catch (Exception ex)
            //{
            //    // Handle your errors here (log them and tell the user that there was an error)
            //}
        }
Exemplo n.º 30
0
 public Product GetProduct(int productId, ShopOwner shopOwner)
 {
     return(db.Products.SingleOrDefault(p => p.Id == productId && p.ShopOwner.Id == shopOwner.Id && !p.DisableDate.HasValue && !p.RemoveDate.HasValue));
 }