Beispiel #1
0
 //添加需求时同时添加对谁的需求
 public int AddDecDemand(DecDemand DecDemand)
 {
     using (AIYunNetContext context = new AIYunNetContext())
     {
         if (DecDemand.GetUserID != 0)
         {
             DecDemandAccept acc = new DecDemandAccept();
             acc.DemandGuid   = DecDemand.Guid;
             acc.GetUserID    = DecDemand.GetUserID;
             acc.PublicUserID = DecDemand.PublishuserID;
             acc.IsAccept     = 0;
             DecDemandAcceptService ser = new DecDemandAcceptService();
             ser.AddDecDemandAccept(acc);
         }
         DecDemand.IsAccept    = 0;
         DecDemand.GetUserID   = DecDemand.GetUserID;
         DecDemand.GetUserType = "";
         context.DecDemand.Add(DecDemand);
         context.SaveChanges();
         return(1);
     }
 }
Beispiel #2
0
        public int UpdateDecDemand(DecDemand DecDemand)
        {
            using (AIYunNetContext context = new AIYunNetContext())
            {
                DecDemand old = context.DecDemand.Find(DecDemand.id);
                DecDemandAcceptService ser        = new DecDemandAcceptService();
                DecDemandAccept        accold     = ser.GetAcceptByGuid(DecDemand.Guid);
                WebBuidingService      buidingSer = new WebBuidingService();

                if (old != null)
                {
                    if (DecDemand.GetUserID != 0)
                    {
                        if (accold != null)
                        {
                            DecDemandAccept oldacc = context.DecDemandAccept.FirstOrDefault(c => c.DemandGuid == accold.DemandGuid);
                            oldacc.GetUserID    = DecDemand.GetUserID;
                            oldacc.PublicUserID = DecDemand.PublishuserID;
                            oldacc.IsAccept     = 0;
                        }
                        else
                        {
                            DecDemandAccept acc = new DecDemandAccept();
                            acc.DemandGuid   = DecDemand.Guid;
                            acc.GetUserID    = DecDemand.GetUserID;
                            acc.PublicUserID = DecDemand.PublishuserID;
                            acc.IsAccept     = 0;
                            ser.AddDecDemandAccept(acc);
                        }
                    }
                    old.IsAccept  = 0;
                    old.GetUserID = DecDemand.GetUserID;

                    old.ownername      = DecDemand.ownername;
                    old.ownertel       = DecDemand.ownertel;
                    old.ProvinceID     = DecDemand.ProvinceID;
                    old.ProvinceName   = DecDemand.ProvinceName;
                    old.OneSentence    = DecDemand.OneSentence;
                    old.IsPublish      = DecDemand.IsPublish;
                    old.Info           = DecDemand.Info;
                    old.EditOn         = DateTime.Now;
                    old.DemandType     = DecDemand.DemandType;
                    old.DemandTypeName = DecDemand.DemandTypeName;
                    old.CityID         = DecDemand.CityID;
                    old.CityName       = DecDemand.CityName;
                    old.buidingSpace   = DecDemand.buidingSpace;
                    old.buidingname    = DecDemand.buidingname;
                    old.HouseType      = DecDemand.HouseType;
                    old.IsPlan         = false;
                    old.IsOut          = false;
                    WebBuiding buiding = buidingSer.GetWebBuidingByGuID(DecDemand.Guid);
                    if (buiding != null)
                    {
                        buidingSer.DeleteWebBuiding(buiding.BuidingID);
                    }

                    context.SaveChanges();
                }
                return(1);
            }
        }