Esempio n. 1
0
        public ActionResult Edit(int id, PROPERTY p, List <string> feature)
        {
            PROPERTY proper   = model.PROPERTies.Find(p.ID);
            var      property = model.PROPERTies.FirstOrDefault(x => x.ID == id);
            var      feat     = model.PROPERTY_FEATURE.Where(x => x.Property_ID == p.ID).ToList();

            model.PROPERTY_FEATURE.RemoveRange(feat);

            property.PropertyName = p.PropertyName;
            property.UnitPrice    = p.UnitPrice;
            property.Price        = p.Price;
            property.BathRoom     = p.BathRoom;
            property.BedRoom      = p.BedRoom;
            property.Content      = p.Content;
            property.Create_post  = p.Create_post;
            property.Created_at   = p.Created_at;
            property.DISTRICT     = p.DISTRICT;
            property.STREET       = p.STREET;
            property.WARD         = p.WARD;
            property.Area         = p.Area;
            property.Status_ID    = p.Status_ID;
            foreach (var featu in feature)
            {
                PROPERTY_FEATURE proferty_fea = new PROPERTY_FEATURE();

                proferty_fea.Feature_ID  = model.FEATUREs.SingleOrDefault(x => x.FeatureName == featu).ID;
                proferty_fea.Property_ID = p.ID;
                model.PROPERTY_FEATURE.Add(proferty_fea);
            }

            model.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public void InsertProjectToDB(Table projects)
        {
            using (var db = new K21T1_Team4Entities1())
            {
                var oStreets = db.STREETs.ToList();

                foreach (var item in projects.Rows)
                {
                    var tPropertyType = item["PropertyType"].ToString();
                    var tStreet_ID    = item["Street"].ToString();
                    var tDistrict_ID  = item["District"].ToString();
                    var tPropertyName = item["PropertyName"].ToString();

                    var a = db.PROPERTY_TYPE.FirstOrDefault(d1 => d1.CodeType == tPropertyType);
                    var b = db.STREETs.FirstOrDefault(s => s.StreetName == tStreet_ID);
                    var c = db.DISTRICTs.FirstOrDefault(d2 => d2.DistrictName == tDistrict_ID);


                    PROPERTY project = new PROPERTY()
                    {
                        PropertyName    = item["PropertyName"].ToString(),
                        PropertyType_ID = a.ID,
                        Street_ID       = db.STREETs.FirstOrDefault(s => s.StreetName == tStreet_ID).ID,
                        District_ID     = db.DISTRICTs.FirstOrDefault(d => d.DistrictName == tDistrict_ID).ID
                    };
                    _context.ReferenceDetails.Add(projects.Header.Contains("ID") ? item["ID"] : project.PropertyName, project);
                    db.PROPERTies.Add(project);
                }
            }
        }
        public ActionResult Create(PROPERTY p)
        {
            var project = new PROPERTY();

            project.PropertyName    = p.PropertyName;
            project.Price           = p.Price;
            project.Avatar          = p.Avatar;
            project.PropertyType_ID = p.PropertyType_ID;
            project.Content         = p.Content;
            project.Created_at      = p.Created_at;
            project.Street_ID       = p.Street_ID;
            project.Ward_ID         = p.Ward_ID;
            project.District_ID     = p.District_ID;
            project.UnitPrice       = p.UnitPrice;
            project.Area            = p.Area;
            project.BedRoom         = p.BedRoom;
            project.BathRoom        = p.BathRoom;
            project.PackingPlace    = p.PackingPlace;
            project.UserID          = p.UserID;
            project.Sale_ID         = p.Sale_ID;
            project.Create_post     = p.Create_post;
            project.Status_ID       = p.Status_ID;
            project.Note            = p.Note;
            db.PROPERTies.Add(project);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
        public ActionResult AddProject(PROPERTY model)
        {
            var pro = new PROPERTY();

            pro.PropertyName     = model.PropertyName;
            pro.Avatar           = model.Avatar;
            pro.Images           = model.Images;
            pro.PropertyType_ID  = model.PropertyType_ID;
            pro.Content          = model.Content;
            pro.Street_ID        = model.Street_ID;
            pro.Ward_ID          = model.Ward_ID;
            pro.District_ID      = model.District_ID;
            pro.Price            = model.Price;
            pro.UnitPrice        = model.UnitPrice;
            pro.Area             = model.Area;
            pro.BedRoom          = model.BedRoom;
            pro.BathRoom         = model.BathRoom;
            pro.PackingPlace     = model.PackingPlace;
            pro.UserID           = model.UserID;
            pro.Created_at       = DateTime.Now;
            pro.Create_post      = DateTime.Now;
            pro.Status_ID        = model.Status_ID;
            pro.Note             = model.Note;
            pro.Updated_at       = DateTime.Now;
            pro.Sale_ID          = model.Sale_ID;
            pro.PROPERTY_FEATURE = model.PROPERTY_FEATURE;
            db.PROPERTies.Add(pro);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public void InsertProjectToDB(Table projects)
        {
            using (var db = new K21T1_Team3Entities())
            {
                foreach (var item in projects.Rows)
                {
                    var property = item["PropertyName"].ToString();
                    var content  = item["Content"].ToString();
                    var protype  = item["PropertyType"].ToString();
                    var street   = item["Street"].ToString();
                    var ward     = item["Ward"].ToString();
                    var district = item["District"].ToString();

                    PROPERTY pro = new PROPERTY()
                    {
                        PropertyName    = property,
                        Content         = content,
                        Price           = int.Parse(item["Price"].ToString()),
                        PropertyType_ID = db.PROPERTY_TYPE.FirstOrDefault(t => t.CodeType == protype).ID,
                        Street_ID       = db.STREETs.FirstOrDefault(s => s.StreetName == street).ID,
                        Ward_ID         = db.WARDs.FirstOrDefault(s => s.WardName == ward).ID,
                        District_ID     = db.DISTRICTs.FirstOrDefault(s => s.DistrictName == district).ID
                    };
                    _context.ReferenceDetails.Add(projects.Header.Contains("ID") ? item["ID"] : pro.PropertyName, pro);
                    db.PROPERTies.Add(pro);
                }
                db.SaveChanges();
            }
        }
Esempio n. 6
0
        public ActionResult EditProject1([Bind(Include = "ID,PropertyName,Avatar,Images,PropertyType_ID,Content,Street_ID,Ward_ID,District_ID,Price,UnitPrice,Area,BedRoom,BathRoom,PackingPlace,UserID,Created_at,Create_post,Status_ID,Note,Updated_at,Sale_ID")] PROPERTY model)
        {
            var pro = db.PROPERTies.Find(model.ID);

            pro.PropertyName     = model.PropertyName;
            pro.Avatar           = model.Avatar;
            pro.Images           = model.Images;
            pro.PropertyType_ID  = model.PropertyType_ID;
            pro.Content          = model.Content;
            pro.Street_ID        = model.Street_ID;
            pro.Ward_ID          = model.Ward_ID;
            pro.District_ID      = model.District_ID;
            pro.Price            = model.Price;
            pro.UnitPrice        = model.UnitPrice;
            pro.Area             = model.Area;
            pro.BedRoom          = model.BedRoom;
            pro.BathRoom         = model.BathRoom;
            pro.PackingPlace     = model.PackingPlace;
            pro.UserID           = model.UserID;
            pro.Created_at       = model.Created_at;
            pro.Create_post      = model.Create_post;
            pro.Status_ID        = model.Status_ID;
            pro.Note             = model.Note;
            pro.Updated_at       = DateTime.Now;
            pro.Sale_ID          = model.Sale_ID;
            pro.PROPERTY_FEATURE = model.PROPERTY_FEATURE;

            db.Entry(pro).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(PROPERTY property)
        {
            property.Avatar      = AvatarU(property);
            property.Images      = ImagesU(property);
            property.Created_at  = DateTime.Now;
            property.Create_post = DateTime.Now; // sua lai sau
            property.UnitPrice   = "VND";
            property.Status_ID   = 1;
            property.UserID      = (int)Session["UserID"];

            if (ModelState.IsValid)
            {
                db.PROPERTY.Add(property);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.District_ID     = new SelectList(db.DISTRICT, "ID", "DistrictName", property.District_ID);
            ViewBag.Status_ID       = new SelectList(db.PROJECT_STATUS, "ID", "Status_Name", property.Status_ID);
            ViewBag.PropertyType_ID = new SelectList(db.PROPERTY_TYPE, "ID", "CodeType", property.PropertyType_ID);
            ViewBag.Street_ID       = new SelectList(db.STREET, "ID", "StreetName", property.Street_ID);
            ViewBag.UserID          = new SelectList(db.USER, "ID", "Email", property.UserID);
            ViewBag.Sale_ID         = new SelectList(db.USER, "ID", "Email", property.Sale_ID);
            ViewBag.Ward_ID         = new SelectList(db.WARD, "ID", "WardName", property.Ward_ID);
            return(View(property));
        }
        public ActionResult Submit([Bind(Exclude = "ID")] PROPERTY newProject)
        {
            String   message;
            int      status;
            DateTime time = DateTime.Now;

            try
            {
                int UserID = int.Parse(Session["userID"].ToString());
                newProject.UserID     = UserID;
                newProject.Updated_at = time;
                newProject.Created_at = time;
                db.PROPERTies.Add(newProject);
                db.SaveChanges();

                message = "Add Success,wait for appover.";
                status  = 1;
            }
            catch (Exception e)
            {
                message = e.Message;
                status  = 0;
            }
            return(Json(new { Status = status, Message = message, JsonRequestBehavior.AllowGet }));
        }
        private string ImagesUPost(PROPERTY p)
        {
            string filename;
            string extension;
            string b;
            string s = "";

            foreach (var file in p.UpImages)
            {
                if (file != null)
                {
                    if (file.ContentLength >= 0)
                    {
                        filename  = Path.GetFileNameWithoutExtension(file.FileName);
                        extension = Path.GetExtension(file.FileName);
                        filename  = filename + DateTime.Now.ToString("yymmssff") + extension;
                        p.Images  = filename;
                        b         = p.Images;
                        s         = string.Concat(s, b, ",");
                        filename  = Path.Combine(Server.MapPath("~/Images"), filename);
                        file.SaveAs(filename);
                    }
                }
            }
            return(s);
        }
        public ActionResult Edit(PROPERTY p)
        {
            PROPERTY en;
            string   s;
            string   b;

            AvatarU(p, out en, out s);
            ImagesU(p, out en, out b);

            en.PROPERTY_TYPE   = p.PROPERTY_TYPE;
            en.PropertyName    = p.PropertyName;
            en.Avatar          = s;
            en.Images          = b;
            en.PropertyType_ID = p.PropertyType_ID;
            en.Content         = p.Content;
            en.Street_ID       = p.Street_ID;
            en.Ward_ID         = p.Ward_ID;
            en.District_ID     = p.District_ID;
            en.Price           = p.Price;
            en.UnitPrice       = "VND";
            en.Area            = p.Area;
            en.BedRoom         = p.BedRoom;
            en.BathRoom        = p.BathRoom;
            en.PackingPlace    = p.PackingPlace;
            en.Status_ID       = 2;
            en.Updated_at      = DateTime.Now;
            en.Note            = p.Note;
            db.SaveChanges();
            return(RedirectToAction("ViewListMyProject", "AgencyProperty"));
        }
        private void AvatarU(PROPERTY p, out PROPERTY en, out string s)
        {
            en = db.PROPERTY.Find(p.ID);
            string filename;
            string extension;

            //try
            //{
            if (p.AvatarUpload != null)
            {
                filename  = Path.GetFileNameWithoutExtension(p.AvatarUpload.FileName);
                extension = Path.GetExtension(p.AvatarUpload.FileName);
                filename  = filename + DateTime.Now.ToString("yymmssff") + extension;
                p.Avatar  = filename;
                s         = p.Avatar;
                filename  = Path.Combine(Server.MapPath("~/Images"), filename);
                p.AvatarUpload.SaveAs(filename);
            }
            else
            {
                s = en.Avatar;
            }
            //}
            //catch (NullReferenceException)
            //{
            //    return
            //}
        }
Esempio n. 12
0
 internal void SetProperty(FRAME frame, PROPERTY property, bool setLogic = true)
 {
     this.Frame = frame;
     if (setLogic)
     {
         if (this.IsMonster())
         {
             ScaleLeft  = ScaleRight = ATK = DEF = Level = Rank = -1;
             IsPendulum = false;
             Attribute  = Frame == FRAME.Spell ? ATTRIBUTE.SPELL : ATTRIBUTE.TRAP;
             Abilities.Clear();
             Property = PROPERTY.Normal;
             Type     = TYPE.NONE;
         }
         else
         {
             if (property.IsSpellPropertyOnly())
             {
                 Attribute = ATTRIBUTE.SPELL;
                 //_Frame = FRAME.Spell;
             }
             else if (property.IsTrapPropertyOnly())
             {
                 Attribute = ATTRIBUTE.TRAP;
                 //_Frame = FRAME.Trap;
             }
         }
     }
     Property = property;
 }
        public IHttpActionResult AssignAgnet(dynamic property)
        {
            db.Configuration.ProxyCreationEnabled = false;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                PROPERTY myproperty = new PROPERTY();
                int      PropertyID = Convert.ToInt16(property.PROPERTYID);
                myproperty = db.PROPERTies.Find(PropertyID);
                if (property == null)
                {
                    return(NotFound());
                }
                myproperty.AGENT_ID = Convert.ToInt16(property.AGENT_ID);
                db.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }



            return(Ok(property));
        }
Esempio n. 14
0
        //public ProjectDriver(SearchResultState context)
        //{
        //    _context = context;
        //}

        public void InsertProjecttoDB(Table givenProjects)
        {
            using (var db = new DemoPPCRentalEntities())
            {
                foreach (var row in givenProjects.Rows)
                {
                    var property = new PROPERTY
                    {
                        PropertyName    = row["PropertyName"],
                        PropertyType_ID = db.PROPERTY_TYPE.ToList().FirstOrDefault(x => x.CodeType == row["PropertyType"]).ID,
                        Status_ID       = db.PROJECT_STATUS.ToList().FirstOrDefault(x => x.Status_Name == row["Status"]).ID,
                        District_ID     = db.DISTRICT.ToList().FirstOrDefault(x => x.DistrictName == row["District"]).ID,
                        Street_ID       = db.STREET.ToList().FirstOrDefault(x => x.StreetName == row["Street"]).ID,
                        Content         = row["Content"],
                        UserID          = db.USER.ToList().FirstOrDefault(x => x.FullName == row["Agency"]).ID,
                        Sale_ID         = db.USER.ToList().FirstOrDefault(x => x.FullName == row["Sale"]).ID,
                        Avatar          = row["Avarta"],
                        Images          = row["Images"],
                        BedRoom         = int.Parse(row["BedRoom"]),
                        BathRoom        = int.Parse(row["BathRoom"]),
                        PackingPlace    = int.Parse(row["PackingPlace"]),
                        Price           = int.Parse(row["Price"]),
                        Area            = row["Area"],
                    };

                    //_context.ReferenceBooks.Add(
                    //        givenProjects.Header.Contains("ID") ? row["ID"] : row["PropertyName"],
                    //        property);

                    db.PROPERTY.Add(property);
                }

                db.SaveChanges();
            }
        }
        private void ImagesU(PROPERTY p, out PROPERTY en, out string s)
        {
            en = db.PROPERTY.Find(p.ID);
            string filename;
            string extension;
            string b;

            s = "";
            if (p.UpImages == null)
            {
                s = en.Images;
            }
            else
            {
                foreach (var file in p.UpImages)
                {
                    try
                    {
                        filename  = Path.GetFileNameWithoutExtension(file.FileName);
                        extension = Path.GetExtension(file.FileName);
                        filename  = filename + DateTime.Now.ToString("yymmssff") + extension;
                        p.Images  = filename;
                        b         = p.Images;
                        s         = string.Concat(s, b, ",");
                        filename  = Path.Combine(Server.MapPath("~/Images"), filename);
                        file.SaveAs(filename);
                    }
                    catch (NullReferenceException)
                    {
                        s = en.Images;
                    }
                }
            }
        }
        public ActionResult projectupdate(PROPERTY projectupdate, int id)
        {
            string   message = "";
            DateTime date    = DateTime.Now;

            try
            {
                //var project = db.PROPERTies.FirstOrDefault(x => x.ID == projectID);
                PROPERTY editProject = db.PROPERTies.Find(id);
                editProject.PropertyName    = projectupdate.PropertyName;
                editProject.Content         = projectupdate.Content;
                editProject.PropertyType_ID = projectupdate.PropertyType_ID;
                editProject.Street_ID       = projectupdate.Street_ID;
                editProject.Ward_ID         = projectupdate.Ward_ID;
                editProject.District_ID     = projectupdate.District_ID;
                editProject.Price           = projectupdate.Price;
                editProject.Area            = projectupdate.Area;
                editProject.BathRoom        = projectupdate.BathRoom;
                editProject.PackingPlace    = projectupdate.PackingPlace;
                editProject.BedRoom         = projectupdate.BedRoom;
                editProject.Status_ID       = projectupdate.Status_ID;
                db.SaveChanges();
                message = "update thanh cong";
            }
            catch (Exception e)
            {
                message = e.Message;
            }
            return(Json(new { Message = message, JsonRequestBehavior.AllowGet }));
        }
Esempio n. 17
0
        public ActionResult PostProject()
        {
            //ViewBag.Message = "Your application description page.";
            var property = new PROPERTY();

            return(View());
        }
        public ActionResult EditMe(int id, PROPERTY p)
        {
            //PROPERTY product;
            PROPERTY en;
            string   s;
            string   b;

            AvatarU(p, out en, out s);
            ImagesU(p, out en, out b);


            en.PROPERTY_TYPE   = p.PROPERTY_TYPE;
            en.PropertyName    = p.PropertyName;
            en.Avatar          = s;
            en.Images          = b;
            en.PropertyType_ID = p.PropertyType_ID;
            en.Content         = p.Content;
            en.Street_ID       = p.Street_ID;
            en.Ward_ID         = p.Ward_ID;
            en.District_ID     = p.District_ID;
            en.Price           = p.Price;
            en.UnitPrice       = p.UnitPrice;
            en.Area            = p.Area;
            en.BedRoom         = p.BedRoom;
            en.BathRoom        = p.BathRoom;
            en.PackingPlace    = p.PackingPlace;
            en.Updated_at      = DateTime.Now;
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public dynamic getPropertyBy(int Reference)
        {
            db.Configuration.ProxyCreationEnabled = false;

            PROPERTY objEmp = new PROPERTY();


            //var area = db.AREAs.Where(xx => xx.AREANAME == Reference).FirstOrDefault();

            try
            {
                objEmp = db.PROPERTies.Find(Reference);


                //objEmp = db.PROPERTies.Where(vv => vv.PROPERTYID ==Reference).ToList();
                if (objEmp == null)
                {
                    dynamic setInvalid = new ExpandoObject();
                    setInvalid.isValid = "false";
                    return(setInvalid);
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(Ok(objEmp));
        }
        public ActionResult Edit(int id, PROPERTY p)
        {
            var product = model.PROPERTies.FirstOrDefault(x => x.ID == id);

            product.PropertyName    = p.PropertyName;
            product.Avatar          = p.Avatar;
            product.Images          = p.Images;
            product.PropertyType_ID = p.PropertyType_ID;
            product.Content         = p.Content;
            product.Street_ID       = p.Street_ID;
            product.Ward_ID         = p.Ward_ID;
            product.District_ID     = p.District_ID;
            product.Price           = p.Price;
            product.UnitPrice       = p.UnitPrice;
            product.Area            = p.Area;
            product.BedRoom         = p.BedRoom;
            product.BathRoom        = p.BathRoom;
            product.UserID          = p.UserID;
            product.PackingPlace    = p.PackingPlace;
            product.Created_at      = p.Created_at;
            product.Create_post     = p.Create_post;
            product.Status_ID       = p.Status_ID;
            product.Note            = p.Note;
            product.Updated_at      = p.Updated_at;
            product.Sale_ID         = p.Sale_ID;

            model.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public IHttpActionResult UnassigAgent(int propID)
        {
            db.Configuration.ProxyCreationEnabled = false;
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            PROPERTY objProperty = new PROPERTY();

            try
            {
                objProperty = db.PROPERTies.Find(propID);
                if (objProperty != null)
                {
                    objProperty.AGENT_ID = null;
                }
                try
                {
                    db.SaveChanges();
                }
                catch (Exception e)
                {
                    return(null);
                }
            }
            catch (Exception)
            {
                return(null);
            }

            return(Ok(objProperty));
        }
        public ActionResult DraftPOST(PROPERTY property)
        {
            if (Session["UserID"] != null)
            {
                property.Avatar      = AvatarUPost(property);
                property.Images      = ImagesUPost(property);
                property.Created_at  = DateTime.Now;
                property.Create_post = DateTime.Now;
                property.UnitPrice   = "VND";
                property.Status_ID   = 1;
                property.UserID      = int.Parse(Session["UserID"].ToString());

                if (ModelState.IsValid)
                {
                    db.PROPERTY.Add(property);
                    db.SaveChanges();
                    return(RedirectToAction("ViewDraftProject", "AgencyProperty"));
                }

                ViewBag.District_ID     = new SelectList(db.DISTRICT, "ID", "DistrictName", property.District_ID);
                ViewBag.Status_ID       = new SelectList(db.PROJECT_STATUS, "ID", "Status_Name", property.Status_ID);
                ViewBag.PropertyType_ID = new SelectList(db.PROPERTY_TYPE, "ID", "CodeType", property.PropertyType_ID);
                ViewBag.Street_ID       = new SelectList(db.STREET, "ID", "StreetName", property.Street_ID);
                ViewBag.UserID          = new SelectList(db.USER, "ID", "Email", property.UserID);
                ViewBag.Sale_ID         = new SelectList(db.USER, "ID", "Email", property.Sale_ID);
                ViewBag.Ward_ID         = new SelectList(db.WARD, "ID", "WardName", property.Ward_ID);
                return(View(property));
            }
            else
            {
                return(RedirectToAction("Login", "Account", new { area = "" }));
            }
        }
Esempio n. 23
0
        public dynamic AddProperty(dynamic property)
        {
            db.Configuration.ProxyCreationEnabled = false;
            var      httpRequest = System.Web.HttpContext.Current.Request;
            PROPERTY prop        = new PROPERTY();



            try
            {
                //  string areaname = property.AREA;
                // string propertype = property.PROPERTYTYPE;
                //  AREA area = db.AREAs.Where(zz => zz.AREANAME == areaname).FirstOrDefault();
                //  PROPERTYTYPE type = db.PROPERTYTYPEs.Where(zz => zz.PROPERTTYPEDESCRIPTION == propertype).FirstOrDefault();
                prop.AREAID              = property.AREA;
                prop.PROPERTYTYPEID      = property.PROPERTYTYPE;
                prop.PROPERTYDESCRIPTION = property.PROPERTYDESCRIPTION;
                prop.ADDRESS             = property.ADDRESS;
                prop.SIZE             = property.SIZE;
                prop.NUMBED           = property.NUMBED;
                prop.NUMBBATH         = property.NUMBBATH;
                prop.GARDEN           = property.GARDEN;
                prop.ADDITIONALINFO   = property.ADDITIONALINFO;
                prop.PROPERTYSTATUSID = 1;
                prop.LISTINGDATE      = DateTime.Now.Date;
                prop.AVAILABLEDATE    = property.AVAILABLEDATE;
                prop.IsExtending      = false;

                db.PROPERTies.Add(prop);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(null);
            }

            try
            {
                RENTALAMOUNT amnt = new RENTALAMOUNT();


                int propertyId = int.Parse(db.PROPERTies
                                           .OrderByDescending(p => p.PROPERTYID)
                                           .Select(r => r.PROPERTYID)
                                           .First().ToString());
                amnt.PROPERTYID = propertyId;
                amnt.AMOUNT     = property.RENTALAMOUNT;
                amnt.DATE       = DateTime.Today;

                db.RENTALAMOUNTs.Add(amnt);
                db.SaveChanges();
            }
            catch (Exception)
            {
                return(null);
            }

            return(true);
        }
        public long Insert(PROPERTY entytiy)
        {
            K21T3_Team1_PPC3129Entities model = new K21T3_Team1_PPC3129Entities();

            db.PROPERTY.Add(entytiy);
            db.SaveChanges();
            return(entytiy.ID);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            PROPERTY property = db.PROPERTY.Find(id);

            db.PROPERTY.Remove(property);
            db.SaveChanges();
            return(RedirectToAction("ViewDraftProject"));
        }
Esempio n. 26
0
 /// <summary>
 /// Check the Property whether it is Property can only go with Trap Card
 /// </summary>
 /// <param name="property"></param>
 /// <returns></returns>
 public static bool IsTrapPropertyOnly(this PROPERTY property)
 {
     if (property == PROPERTY.Counter)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 27
0
 public static string GetString(this PROPERTY property)
 {
     if (property == PROPERTY.QuickPlay)
     {
         return("Quick-Play");
     }
     return(property.ToString());
 }
Esempio n. 28
0
        public dynamic UnarchivePropertyDetails(int id)
        {
            PROPERTY updateSTatus = new PROPERTY();

            updateSTatus = db.PROPERTies.Find(id);
            updateSTatus.PROPERTYSTATUSID = 1;
            db.SaveChanges();
            return(Ok());
        }
Esempio n. 29
0
        private static void LogPROPERTY(PROPERTY prop, int i, string propertyHeader, bool isPrivate)
        {
            string propertyValue = isPrivate ? string.Empty.PadRight(prop.propValue.Length, '*') : prop.propValue;

            Log.Trace(propertyHeader + "index=" + i.ToString());
            Log.Trace(propertyHeader + "propName=" + prop.propName);
            Log.Trace(propertyHeader + "propValue=" + propertyValue);
            Log.Trace(propertyHeader + "propType=" + prop.propType);
            Log.Trace(propertyHeader + "propGroup=" + prop.propGroup);
        }
        public ActionResult Delete(int?id)
        {
            PROPERTY property = db.PROPERTY.Find(id);

            if (property == null)
            {
                return(HttpNotFound());
            }
            return(View(property));
        }
Esempio n. 31
0
	/// <summary>
	/// Retrieve object header, links and properties.
	/// </summary>
	/// <param name="header">In/Out header value.</param>
	/// <param name="links">Array of object links.</param>
	/// <param name="props">Array of object properties.</param>
	public void Retrieve( ref HEADER header, out LINK[] links,
						  out PROPERTY[] props )
	{
		#region debug info
#if (DEBUG)
		Debug.Print( "-> ODB.Retrieve( {0}, {1} )", header.ID, header.Type );
#endif
		#endregion

		List<PROPERTY> _props = new List<PROPERTY>();	// list to store properties of object
		List<LINK> _links = new List<LINK>();	// list to store child proxy objects
		DbDataReader dr = null;
		DbCommand cmd = null;
		// init out parameters
		links = null;
		props = null;

		// open connection and start new transaction if required
		TransactionBegin();
		try {
			// get object header
			HEADER newHeader = get_header( header.ID );

			if( header.Stamp == newHeader.Stamp ) {
				header = newHeader;
				// close connection and commit transaction if required
				TransactionCommit();
				return;
			}

			#region retrive props from _properties
			cmd = new SqlCommand( string.Format(
					"SELECT [Name], [Value] FROM [dbo].[_properties] WHERE [ObjectID] = {0}",
					header.ID) );
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;

			dr = cmd.ExecuteReader( CommandBehavior.SingleResult );
			try {
				// read all simple properties of object
				while( dr.Read() ) {
					// read properties from row
					string name = (string) dr["Name"];
					object val	= dr["Value"];

					// convert byte array to memory stream
					if( val.GetType() == typeof(Byte[] ) ) {
						val = new PersistentStream((Byte[])val );
					}
					// build PersistentProperty upon recieved name and value and
					// save property in collection
					_props.Add( new PROPERTY( name, new ValueBox(val), PROPERTY.STATE.New ));
				}
			} finally {
				// Dispose SqlDataReader
				dr.Dispose();
			}
			#endregion

			#region retrive props from _images
			cmd = new SqlCommand( string.Format(
				"SELECT [Name] FROM [dbo].[_images] WHERE [ObjectID] = {0}",
				header.ID) );
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;

			SqlDataAdapter da = new SqlDataAdapter( (SqlCommand)cmd );
			DataTable dt = new DataTable(); // table for object proxy properties

			da.Fill( dt ); // fill table
			DataTableReader dtr = new DataTableReader(dt);
			try {
				while( dtr.Read() ) {
					// save data from SqlDataReader because we need non SequentialAccess in datarow
					string name = (string) dtr["Name"];
					// save property in collection
					_props.Add( new PROPERTY( name,
											  new ValueBox( read_blob( header.ID, name ) ),
											  PROPERTY.STATE.New ));
				}
			} finally {
				dtr.Dispose();
			}
			#endregion

			#region retrive links
			cmd = new SqlCommand( string.Format(
				"SELECT [ID], [ObjectName], [ObjectType], [TimeStamp]\n" +
				"FROM [dbo].[_objects]\n" +
				"WHERE [ID] IN (SELECT Child FROM [dbo].[_links] WHERE Parent = {0})",
				header.ID) );
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;

			dr = cmd.ExecuteReader( CommandBehavior.SingleResult );
			try {
				while( dr.Read() ) {
					// save child header
					_links.Add( new LINK(
						new HEADER((string) dr["ObjectType"],
							Convert.ToInt32( dr["ID"] ),
							Convert.ToDateTime( dr["TimeStamp"] ),
							(string) dr["ObjectName"] ),
							LINK.STATE.New));
				}
			} finally { dr.Dispose(); }
			#endregion

			props = _props.ToArray();
			links = _links.ToArray();
			header = newHeader;
		} catch( Exception ex ) {
			#region debug info
#if (DEBUG)
			Debug.Print( "[ERROR] @ ODB.Retrive: {0}", ex.ToString() );
#endif
			#endregion
			// rollback failed transaction
			TransactionRollback();
			throw;
		}
		// close connection and commit transaction if required
		TransactionCommit();

		#region debug info
#if (DEBUG)
		Debug.Print( "<- ODB.Retrieve({0}, {1})", header.ID, header.Type );
#endif
		#endregion
	}
Esempio n. 32
0
	/// <summary>
	/// Save object header, links and properties to storage.
	/// </summary>
	/// <param name="header">In/Out header value.</param>
	/// <param name="links">Array of modified object links.</param>
	/// <param name="props">Array of modified object properties.</param>
	/// <param name="mlinks">Array of new object links.</param>
	/// <param name="mprops">Array of new object properties.</param>
	public void Save( ref HEADER header, LINK[] links, PROPERTY[] props,
					  out LINK[] mlinks, out PROPERTY[] mprops )
	{
		#region debug info
#if (DEBUG)
		Debug.Print( "-> ODB.Save( {0}, {1}, {2}, {3}, {4} )",
					header.ID, header.Type, 
					header.Stamp, props.GetUpperBound( 0 ),
					links.GetUpperBound( 0 ) );
#endif
		#endregion

		DbCommand cmd = null;			// other puroses
		List<PROPERTY> _props = null;	// list for collecting current object properties
		int objID;						// object ID

		// initialize out parameters
		mlinks = null;
		mprops = null;

		// open connection and start new transaction if required
		TransactionBegin();
		try {
			#region create new object proxy if it is new or check it's stamp
			// assign command which will insert or (check, update) object record in DB
			if( header.ID == 0 ) {
				// this is new object. Creating script for insertion of object
				cmd =
					new SqlCommand(
						"\nINSERT INTO [dbo].[_objects] ( [ObjectName], [ObjectType] ) " +
						"VALUES ( @Name, @Type );\n" +
						/*save inserted object ID*/
						"SET @ID = SCOPE_IDENTITY();");
				cmd.Connection = m_con;
				cmd.Transaction = m_trans;
				// add proxy name parameter
				cmd.Parameters.Add(new SqlParameter("@Name", header.Name));
				// add proxy name parameter
				cmd.Parameters.Add(new SqlParameter("@Type", header.Type));
				// add proxy ID parameter
				cmd.Parameters.Add(new SqlParameter("@ID", SqlDbType.Int));
				cmd.Parameters["@ID"].Direction = ParameterDirection.Output;
			} else {
				// check object stamp. If it is newer then current -> raise error
				cmd = new SqlCommand( string.Format(
					"DECLARE @_id AS Int; SET @_id = @ID;\n" +
					"IF ((SELECT [TimeStamp] FROM [dbo].[_objects] WHERE [ID] = @_id) > @Stamp) " +
					"RAISERROR( '{0}', 11, 1 );",
					ERROR_CHANGED_OBJECT ) );
				cmd.Connection = m_con;
				cmd.Transaction = m_trans;
				// add proxy ID parameter
				cmd.Parameters.Add(new SqlParameter("@ID", header.ID));
				// add proxy stamp parameter
				cmd.Parameters.Add( new SqlParameter("@Stamp", header.Stamp));
				// proxy name is always updated
				cmd.CommandText += "UPDATE [dbo].[_objects] SET [ObjectName] = @Name WHERE [ID] = @_id";

				// add proxy name parameter
				cmd.Parameters.Add( new SqlParameter( "@Name", header.Name) );
			}

			// execute batch
			cmd.ExecuteNonQuery();
			// get proxy ID returned by batch execution
			objID = Convert.ToInt32( cmd.Parameters["@ID"].Value );
			#endregion

			// create new command
			cmd = new SqlCommand("");
			cmd.Connection = m_con;
			cmd.Transaction = m_trans;
			_props = new List<PROPERTY>();

			// iterate through received properties
			for( int i = 0; i < props.Length; i++ ) {
				// check for property state and type for different processing
				if( props[i].State == PROPERTY.STATE.Deleted ) {
					// just delete property from _properties/_images table
					cmd.CommandText += string.Format(
						"DELETE FROM [dbo].[_properties] WHERE [ObjectID] = {0} AND [Name] = '{1}'; \n" +
						"IF @@ROWCOUNT = 0 BEGIN                                                    \n" + 
						"    DELETE FROM [dbo].[_images] WHERE [ObjectID] = {0} AND [Name] = '{1}'; \n" +
						"END;                                                                       \n",
						objID, props[i].Name );
				} else if( props[i].Value.ToObject() is PersistentStream &&
						   (props[i].Value.ToObject() as PersistentStream).Length > 7900 ) {
					// save large stream property: 7900 is maximum length of sql_variant field in
					// _properties table because SQL Server limits maximum row size to 8060 bytes,
					// so save stream property as blob
					save_blob( objID, props[i].Name, (PersistentStream)props[i].Value,
							   props[i].State == PROPERTY.STATE.New );
				} else {
					// convert property value to sql_variant capable type
					object value;
					if( props[i].Value.ToObject() is PersistentStream ) {
						// this is a little stream, so convert stream value to byte array
						PersistentStream s = props[i].Value.ToObject() as PersistentStream;
						byte[] buffer = new byte[s.Length];
						s.Seek( 0, SeekOrigin.Begin );
						s.Read( buffer, 0, (int)s.Length );
						value = buffer;
					} else if( props[i].Value.ToObject().GetType() == typeof(DateTime) ) {
						// DateTime property must be converted to precision of sql server before save
						value = datetime_to_sql( (DateTime)props[i].Value );
						// add to changed properies list to return to client
						_props.Add( new PROPERTY(props[i].Name, new ValueBox(value), PROPERTY.STATE.Changed) );
					} else {
						// no convertion is needed
						value = props[i].Value.ToObject();
					}

					// compose sql command to update/insert data into _properties table
					if( props[i].State == PROPERTY.STATE.Changed ) {
						// compose UPDATE command (if this is binary property change, add
						// some extra processing: _images can contain this property already)
						cmd.CommandText += string.Format(
							"UPDATE [dbo].[_properties] SET [Value] = @P{2} WHERE [ObjectID] = {0} AND [Name] = '{1}';     \n" +
							(!(props[i].Value.ToObject() is PersistentStream) ? "" :
							"IF @@ROWCOUNT = 0 BEGIN                                                                       \n" +
							"    DELETE FROM [dbo].[_images] WHERE [ObjectID] = {0} AND [Name] = '{1}';                    \n" +
							"    INSERT INTO [dbo].[_properties] ([ObjectID], [Name], [Value]) VALUES ({0}, '{1}', @P{2}); \n" +
							"END;                                                                                          \n"),
							objID, props[i].Name, i );
					} else {
						// compose INSERT command
						cmd.CommandText += string.Format(
							"INSERT INTO [dbo].[_properties] ([ObjectID], [Name], [Value]) VALUES ({0}, '{1}', @P{2}); \n",
							objID, props[i].Name, i );
					}
					cmd.Parameters.Add( new SqlParameter( "@P" + i, value ) );
				}
			}

			// iteration throught links
			foreach( LINK link in links ) {
				// check link action
				if( link.State == LINK.STATE.New ) {
					// add new link to DB
					cmd.CommandText += string.Format(
						"INSERT INTO [dbo].[_links] ([Parent], [Child]) VALUES ({0}, {1}); \n",
						objID, link.Header.ID );
				} else if( link.State == LINK.STATE.Deleted ) {
					// delete link from DB
					cmd.CommandText += string.Format(
						"DELETE FROM [dbo].[_links] WHERE [Parent] = {0} AND [Child] = {1}; \n",
						objID, link.Header.ID );
				}
			}

			// executing batch
			if( cmd.CommandText != "" ) cmd.ExecuteNonQuery();

			// return proxy properties
			header = get_header( objID );
			// and changed properies if exists
			if( _props.Count > 0 )
				mprops = _props.ToArray();
		} catch( Exception ex ) {
			#region debug info
#if (DEBUG)
			Debug.Print( "[ERROR] @ ODB.Save: {0}", ex.ToString() );
#endif
			#endregion
			// rollback failed transaction
			TransactionRollback();
			throw;
		}
		// close connection and commit transaction if required
		TransactionCommit();

		#region debug info
#if (DEBUG)
		Debug.Print( "<- ODB.Save(ID:{0}, Type:'{1}', Name:'{2}', Stamp:'{3}' )",
					header.ID, header.Type, header.Name, header.Stamp );
#endif
		#endregion
	}