Esempio n. 1
0
        public string CreateUrl(UserLot userLot)
        {
            if (userLot.idStatus == 1)
            {

                string path = RouteTable.Routes.GetVirtualPath(null, "editlot",
                    new RouteValueDictionary()
                {
                    {"editlot", userLot.IdLot}
                }).VirtualPath;

                return string.Format("<a href='{0}'>Изменить</a>",
                    path);
            }
            return string.Format("<a href='' class='disabled'>Изменить</a>");;
        }
Esempio n. 2
0
        protected void saveBtn_Click(object sender, EventArgs e)
        {
            Page.Validate();

            if (Page.IsValid)
            {

                int lotId;
                int.TryParse((string)Page.RouteData.Values["editlot"]
                                ?? Request.QueryString["editlot"], out lotId);

                if (lotId !=0)
                {
                    using (AuctionEntities au = new AuctionEntities())
                    {
                        using (var tran = au.Database.BeginTransaction())
                        {
                            try
                            {
                                lot = au.Lots.First(l => l.IdLot == lotId);
                                AddLot(lot, lot.StartDate, au);
                                au.SaveChanges();
                                tran.Commit();
                                lblError.Text = "Лот успешно изменен!";
                                MultiView.ActiveViewIndex = 1;

                                Methods.UpdateLotsStatus();

                            }
                            catch (Exception)
                            {
                                tran.Rollback();
                            }
                        }
                    }
                }
                else
                {
                    HttpPostedFile ps = Request.Files["filefield"];
                    if ((ps != null) && (ps.ContentLength <= 0))
                    {
                        lblError.Text = "Изображение не выбрано!";
                        return;
                    }

                    using (AuctionEntities au = new AuctionEntities())
                    {
                        using (var tran = au.Database.BeginTransaction())
                        {
                            try
                            {
                                Lot newLot = new Lot();
                                newLot.StartDate = DateTime.Now;
                                newLot.StartPrice = Convert.ToDecimal(startPriceBox.Text);
                                newLot.CurrentPrice = Convert.ToDecimal(startPriceBox.Text);
                                newLot.Status = true;
                                AddLot(newLot, DateTime.Now, au);

                                int userId = au.Users
                                        .Where(u => u.Login == HttpContext.Current.User.Identity.Name)
                                        .Select(u => u.Id)
                                        .First();
                                UserLot userLot = new UserLot();
                                userLot.IdLot = newLot.IdLot;
                                userLot.IdUser = userId;
                                userLot.idStatus = 1;
                                Methods.AddUserLot(userLot, au);
                                au.SaveChanges();
                                tran.Commit();
                                lblError.Text = "Лот успешно добавлен!";
                                MultiView.ActiveViewIndex = 1;

                                Methods.UpdateLotsStatus();
                            }
                            catch (Exception)
                            {
                                tran.Rollback();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 protected string GetSeller(int lotId)
 {
     if (au.UserLots.Count(ul => ul.IdLot == lotId) != 0)
         UserLot = au.UserLots.First(ul => ul.IdLot == lotId && (ul.idStatus == 1 || ul.idStatus == 4));
     return UserLot.User.Name;
 }
Esempio n. 4
0
 private void AddUserLot(int userId, int statusId)
 {
     UserLot ul = new UserLot();
     ul.IdUser = userId;
     ul.IdLot = Lot.IdLot;
     ul.idStatus = statusId;
     Methods.AddUserLot(ul, au);
 }
Esempio n. 5
0
 protected int FindUser(int lotId, int statusId)
 {
     UserLot = au.UserLots.First(ul => ul.IdLot == lotId && ul.idStatus == statusId);
     return UserLot.IdUser;
 }