public Location CreateLocation(Location location)
 {
     try
     {
         if (location != null)
         {
             catalogDAO.CreateLocation(location);
         }
     }
     catch (Exception)
     {
         throw new Exceptions.UserException("Catalog item location creation failed.");
     }
     return location;
 }
 public Location CreateLocation(Location location)
 {
     try
     {
         using (TransactionScope ts = new TransactionScope())
         {
             context.Locations.AddObject(location);
             context.SaveChanges();
             ts.Complete();
             return location;
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            Location location = new Location();
            location.Name = NameTextBox.Text;
            location.CreatedBy = Utilities.Membership.GetCurrentLoggedInUser().UserID;
            location.CreatedDate = DateTime.Now;

            CatalogManager manager = new CatalogManager();

            try
            {
                manager.CreateLocation(location);
            }
            catch (Exception)
            {
                ErrorLabel.Text = "Create Location Failed";
            }
        }
        public Location UpdateLocation(Location location)
        {
            try
            {
                Location tempLocation = (from l in context.Locations
                                         where l.LocationID == location.LocationID
                                         select l).FirstOrDefault<Location>();

                if (location.Name != string.Empty)
                {
                    tempLocation.Name = location.Name;
                }

                using (TransactionScope ts = new TransactionScope())
                {
                    context.SaveChanges();
                    ts.Complete();
                    return tempLocation;
                }
            }
            catch (Exception)
            {
                throw new CatalogException("Location Update Failed.");
            }
        }
        public void DeleteLocation(Location location)
        {
            try
            {
                Location persistedLocation = (from l in context.Locations
                                              where l.LocationID == location.LocationID
                                              select l).First<Location>();

                using (TransactionScope ts = new TransactionScope())
                {
                    context.Locations.DeleteObject(persistedLocation);
                    context.SaveChanges();
                    ts.Complete();
                }
            }
            catch (Exception)
            {
                throw new CatalogException("Delete Location Failed.");
            }
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Locations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLocations(Location location)
 {
     base.AddObject("Locations", location);
 }
 /// <summary>
 /// Create a new Location object.
 /// </summary>
 /// <param name="locationID">Initial value of the LocationID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="createdBy">Initial value of the CreatedBy property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static Location CreateLocation(global::System.Int32 locationID, global::System.String name, global::System.Int32 createdBy, global::System.DateTime createdDate)
 {
     Location location = new Location();
     location.LocationID = locationID;
     location.Name = name;
     location.CreatedBy = createdBy;
     location.CreatedDate = createdDate;
     return location;
 }
        public Location UpdateLocation(Location location)
        {
            try
            {
                if (location != null && location.Name != string.Empty)
                {
                    catalogDAO.UpdateLocation(location);
                }

            }
            catch (Exception)
            {
                throw new Exceptions.UserException("Catalog item location updating failed.");
            }
            return location;
        }
 public void DeleteLocation(Location location)
 {
     try
     {
         if (location != null)
         {
             catalogDAO.DeleteLocation(location);
         }
     }
     catch (Exception)
     {
         //throw new Exceptions.UserException("Catalog item location deletion failed.");
     }
 }