コード例 #1
0
ファイル: LandlordContext.cs プロジェクト: jackweldon/pos
        public static int CreateLandlord(Landlord entity)
        {
            try
            {

                using (var ctx = new PosContext())
                {
                    var found = ctx.Landlord.FirstOrDefault(a => a.Email == entity.Email);
                    if (found == null)
                    {
                        var model = ctx.Landlord.Add(entity);
                        ctx.SaveChanges();
                        AgencyContext.AddNewLandlord(model);
                        return model.Id;
                    }
                    else
                    {
                        //TODO If landlord is found he might have an account, maybe with another agency
                        /*TODO HE May also be created without being invited to the site so he has no login so need to check
                         * TODO whether or not the agency want to link him to one of the entities within their database
                         *
                        */

                    }
                    return -1;

                }

            }
            catch (Exception ex)
            {
                return -1;
            }
        }
コード例 #2
0
ファイル: LandlordsController.cs プロジェクト: jackweldon/pos
        public ActionResult Create(Landlord landlord)
        {
            if (ModelState.IsValid)
            {
                LandlordContext.CreateLandlord(landlord);
                return RedirectToAction("Index");
            }

            return View(landlord);
        }
コード例 #3
0
ファイル: AgencyContext.cs プロジェクト: jackweldon/pos
        public static Landlord AddNewLandlord(Landlord entity)
        {
            try
            {
                using (var ctx = new PosContext())

                {
                    Agency thisAgency = GlobalVariables.GetAgentsAgency;
                    AgencyLandlords AgencyLandlord = new AgencyLandlords
                    {
                        AgencyId = thisAgency.Id,
                        LandlordId = entity.Id
                    };
                    ctx.AgencyLandlords.Add(AgencyLandlord);
                    ctx.SaveChanges();
                    return (entity);
                }

            }
            catch (Exception ex)
            {
                return null;
            }
        }
コード例 #4
0
ファイル: AccountController.cs プロジェクト: jackweldon/pos
        public bool CreateLandlord(FormCollection data, string userid)
        {
            string Forename = Convert.ToString(data["ForeName"]);
            string Email = Convert.ToString(data["Email"]);
            string PostCode = Convert.ToString(data["PostCode"]);
            string Address = Convert.ToString(data["Address"]);
            string Country = Convert.ToString(data["Country"]);
            string City = Convert.ToString(data["City"]);
            DateTime Dob = Convert.ToDateTime(data["Dob"]);
            string PhoneNumber = Convert.ToString(data["PhoneNumber"]);
            string Lastname = Convert.ToString(data["Lastname"]);

            var landlord = new Landlord
            {
                UserId = userid,
                Email = Email,
                Forename = Forename,
                PostCode = PostCode,
                AddressLine = Address,
                Country = Country,
                City = City,
                Dob = Dob,
                PhoneNumber = PhoneNumber,
                Lastname = Lastname
            };
            if (LandlordContext.CreateLandlord(landlord) != -1) return true;

            return false;

        }