示例#1
0
        public ActionResult Index(int customerId, CreateProjectFromUI project)
        {
            using (var connection = this.getConnection())
            {
                try
                {
                    int newProjectId = this.CreateProject(customerId, project, connection);
                    this.CreateRooms(customerId, newProjectId, connection, project);
                    this.AttachProjectToCustomer(customerId, newProjectId, connection);

                    //  This creates a quote as well.  This needs to stop post beta
                    Project Quote = new Project();
                    Quote.FKParentProject = newProjectId;
                    JSONController jc = new JSONController();
                    jc.ProjectCopy(Quote, (int)Status.Quote);

                    @ViewBag.success = true;
                    @ViewBag.message = "Project created!";
                }
                catch (SqlException e)
                {
                    @ViewBag.success = false;
                    @ViewBag.message = e.Message;
                }
            }

            return(View("passFail"));
        }
示例#2
0
        private int CreateProject(int customerId, CreateProjectFromUI project, SqlConnection connection)
        {
            //  TODO - standardize this using the Projects Service.
            var p = new DynamicParameters();

            p.Add("@Deadline", project.dateComplete);
            p.Add("@Name", project.Name);
            p.Add("@FKProjectType", project.projectType);
            p.Add("@newid", DbType.Int32, direction: ParameterDirection.ReturnValue);
            p.Add("@FKStatus", (int)Status.Project);

            connection.Execute("Project_Create", p, commandType: CommandType.StoredProcedure);
            return(p.Get <int>("@newid"));
        }
示例#3
0
        //  There are four possible room types.  This iterates through the room types, figures out
        //  how many are on the project, and creates the room instances where need be.
        //  This could be done more elegantly, but I didn't figure that out in my timebox, so quick and
        //  dirty it is - BMW.
        private void CreateRooms(int customerId, int newProjectId, SqlConnection connection, CreateProjectFromUI project)
        {
            RoomsCategory rc = new RoomsCategory();

            rc.Name = "laundry";
            for (var i = 0; i < project.laundry; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
            rc.Name = "bathroom";
            for (var i = 0; i < project.bathrooms; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
            rc.Name = "kitchen";
            for (var i = 0; i < project.kitchens; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
            rc.Name = "outdoor";
            for (var i = 0; i < project.outdoor; i++)
            {
                var p = new DynamicParameters();
                p.Add("@FKRoomsCategory", rc.SpaceType);
                p.Add("@FKProject", newProjectId);
                connection.Execute("Room_Create", p, commandType: CommandType.StoredProcedure);
            }
        }