public void AssignProjectToClient(ClientProjectViewModel assignProject)
        {
            //var getClient = (from user in _db.Clients
            //                 join clientproject in _db.ClientProject on user.ClientID equals clientproject.ClientID

            //                 where user.ClientID == assignProject.ClientID
            //                 select user.ClientID).FirstOrDefault();



            foreach (var x in assignProject.ProjectID)
            {
                var getClientProject = (from clientproject in _db.ClientProject
                                        //join client in _db.Clients on clientproject.ClientID equals client.ClientID
                                        //join project in _db.Projects on clientproject.ProjectID equals project.ProjectID
                                        where clientproject.ClientID == assignProject.ClientID && clientproject.ProjectID == x
                                        select clientproject).Any();
                if (getClientProject == false)
                {
                    var projectAssign = new ClientProject
                    {
                        ClientID  = assignProject.ClientID,
                        ProjectID = x
                    };
                    _db.ClientProject.Add(projectAssign);
                }
                _db.SaveChanges();
            }
        }
Exemplo n.º 2
0
        public ActionResult ClientDetails(int?id)
        {
            ViewBag.error = id == null;
            ClientProject clientProject = db.ClientProjects.Include("Client").FirstOrDefault(x => x.ProjectId == id);

            ViewBag.Project = clientProject == null;
            return(View(clientProject));
        }
Exemplo n.º 3
0
        // GET: Projects/Edit/5
        public ActionResult ChangeProjectBillRate(int?id)
        {
            ViewBag.error = id == null;
            ClientProject project = db.ClientProjects.Find(id);

            ViewBag.project = project == null;

            return(View(project));
        }
        public ActionResult Projects()
        {
            System.Diagnostics.Debug.WriteLine("qqqqqqqqqqqqqqqqqqqqqqqqqqq" + clientId);
            string        command = null;
            ClientProject clas    = new ClientProject();

            //int id=Convert.ToInt32(companyid);
            if (clientId != null)
            {
                command = "select * from Project where clientCompanyId=@id";
            }
            else
            {
                command = "select * from Project";
            }
            projectList = new List <Project>();
            con.Open();
            SqlCommand comd = new SqlCommand(command, con);

            comd.Parameters.AddWithValue("@id", Convert.ToInt32(clientId));
            SqlDataReader projectdata = comd.ExecuteReader();

            while (projectdata.Read())
            {
                project             = new Project();
                project.projectName = projectdata["projectName"].ToString();
                project.projectId   = Convert.ToInt32(projectdata["projectId"]);
                project.deadline    = Convert.ToDateTime(projectdata["deadline"]);
                //int x= Convert.ToInt32(projectdata["status"]);
                project.status          = projectdata["status"].ToString();
                project.clientCompanyId = Convert.ToInt32(projectdata["clientCompanyId"]);
                project.budget          = Convert.ToInt32(projectdata["budget"]);
                projectList.Add(project);
            }
            clientId     = null;
            clas.project = projectList;
            con.Close();
            //List<SelectListItem> li=new List<SelectListItem>()
            List <Client> com = new List <Client>();
            Client        c   = new Client();

            con.Open();
            SqlCommand    cmd  = new SqlCommand("select * from Client", con);
            SqlDataReader data = cmd.ExecuteReader();

            while (data.Read())
            {
                c            = new Client();
                c.clientId   = Convert.ToInt32(data["id"]);
                c.clientName = data["clientName"].ToString();
                com.Add(c);
            }
            con.Close();
            clas.client = com;
            return(View(clas));
        }
Exemplo n.º 5
0
        public void PostClient(ClientProjectViewModel client)
        {
            try
            {
                //using (IDbConnection db = new SqlConnection(_connectionString))
                //{
                //    var parameter = new DynamicParameters();

                //    foreach (var items in client.ProjectID)
                //    {
                //        parameter.Add("@ProjectID", items);
                //    }
                //    parameter.Add("@ClientFirstName", client.ClientFirstName);
                //    parameter.Add("@ClientLastName", client.ClientLastName);
                //    parameter.Add("@ClientOffice", client.ClientOffice);
                //    parameter.Add("@OfficeAddress", client.OfficeAddress);
                //    parameter.Add("@ClientContactNumber", client.ClientContactNumber);
                //    db.Execute("InsertIntoClientProjects", parameter, commandType: CommandType.StoredProcedure);
                //_db.Clients.Add(client.ClientID, client.ClientFirstName, client.ClientLastName, client.ClientOffice, client.ClientContactNumber);
                var getContact = _db.Clients.Where(x => x.ClientContactNumber == client.ClientContactNumber && x.ClientFirstName == client.ClientFirstName && x.ClientLastName == client.ClientLastName);
                if (getContact.Count() == 0)
                {
                    var clientDetail = new Clients
                    {
                        ClientFirstName     = client.ClientFirstName,
                        ClientLastName      = client.ClientLastName,
                        ClientContactNumber = client.ClientContactNumber,
                        ClientOffice        = client.ClientOffice,
                        OfficeAddress       = client.OfficeAddress
                    };
                    _db.Clients.Add(clientDetail);
                    _db.SaveChanges();
                    foreach (var x in client.ProjectID)
                    {
                        var clientProject = new ClientProject
                        {
                            ClientID  = clientDetail.ClientID,
                            ProjectID = x
                        };
                        _db.ClientProject.Add(clientProject);
                    }
                    _db.SaveChanges();
                }
                else
                {
                    message = "Cant enter data";
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 6
0
        private Tuple <ServerProject, ClientProject> InitProject(GenerateRequest request, IDisk serverDisk, IDisk clientDisk)
        {
            DataModel dataModel = new DataModel();
            var       jObject   = JObject.Parse(request.Data, new JsonLoadSettings {
                CommentHandling = CommentHandling.Load, DuplicatePropertyNameHandling = DuplicatePropertyNameHandling.Error
            });

            dataModel.Load(jObject);
            var collection = new ResourceCollection(dataModel);
            var userClass  = dataModel.Classes.FirstOrDefault(c => c.Name == "User");

            if (userClass == null)
            {
                throw new Exception("The model must contain a user class.");
            }
            if (userClass.Properties.Any(p => p.Name == "PasswordHash" || p.Name == "Password"))
            {
                throw new Exception("You must not explicitly set passwords for users. A password hash will be automatically added to the user class.");
            }
            CheckMandatoryUserProperty(userClass, "Email");
            CheckMandatoryUserProperty(userClass, "UserName");
            userClass.Properties.Add(new Property
            {
                Name         = "PasswordHash",
                IsServerOnly = true,
                BuiltInType  = BuiltInType.String
            });
            var seedStore = new SeedDataStore(collection);

            seedStore.Load(jObject);
            var serverPlugin  = GetServerPlugin(request);
            var serverProject = new ServerProject
            {
                Config             = serverPlugin.Config,
                Disk               = serverDisk,
                ResourceCollection = collection,
                SeedStore          = seedStore,
                Templates          = serverPlugin.Templates
            };
            var clientPlugin  = GetClientPlugin(request);
            var clientProject = new ClientProject
            {
                Config             = clientPlugin.Config,
                Disk               = clientDisk,
                ResourceCollection = collection,
                SeedStore          = seedStore,
                Templates          = clientPlugin.Templates
            };

            return(Tuple.Create(serverProject, clientProject));
        }
Exemplo n.º 7
0
        public ActionResult ChangeProjectBillRate(ClientProject project)
        {
            var editedProj = db.ClientProjects.SingleOrDefault(x => x.id == project.id);

            if (ModelState.IsValid)
            {
                editedProj.BillRate        = project.BillRate;
                db.Entry(editedProj).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("ClientProjectIndex"));
            }

            return(View(project));
        }
Exemplo n.º 8
0
 public IActionResult Create(ClientProject project)
 {
     if (ModelState.IsValid)
     {
         try
         {
             project.MakeProject(SessionUtils.GetSessionClientId(HttpContext.Session));
             return(RedirectToAction("Index", "Projects"));
         }
         catch (DBWriteException)
         {
             return(View("Error"));
         }
     }
     else
     {
         return(View("Error"));
     }
 }
Exemplo n.º 9
0
        //This method is used for get all client projects
        public List <ClientProject> GetAllClientProject()
        {
            List <ClientProject> ClientProjects = new List <ClientProject>();


            //var q = (from pd in this.Projects
            //         join
            //         od in this.Clients on
            //         pd.ClientID equals od.Id
            //         orderby pd.ProjectName
            //         select new ClientProject
            //         {
            //             Name = od.Name + "-" + pd.ProjectName,
            //             Id = pd.ProjectID

            //         }).ToList();
            try
            {
                //IEnumerable<Project> prj= Projects
                //                .Include("Client")
                //               .Select(x => x).ToList();


                foreach (var a in Projects)
                {
                    ClientProject cli = new ClientProject();
                    cli.Id   = a.CustomerId;
                    cli.Name = a.ProjectName;
                    ClientProjects.Add(cli);
                }
                return(ClientProjects);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }