コード例 #1
0
        public User Create(User item)
        {
            var createOrganizationentity = _context.Users.Add(item).Entity;

            _context.SaveChanges();
            return(createOrganizationentity);
        }
コード例 #2
0
        public Enterprise Create(Enterprise item)
        {
            var createEnterprisesentity = _context.Enterprises.Add(item).Entity;

            _context.SaveChanges();
            return(createEnterprisesentity);
        }
コード例 #3
0
        public Country Create(Country item)
        {
            var createCountryentity = _context.Сountries.Add(item).Entity;

            _context.SaveChanges();
            return(createCountryentity);
        }
コード例 #4
0
        public Family Create(Family item)
        {
            var createFamilyentity = _context.Familys.Add(item).Entity;

            _context.SaveChanges();
            return(createFamilyentity);
        }
コード例 #5
0
        public Department Create(Department item)
        {
            var createDepartmententity = _context.Departments.Add(item).Entity;

            _context.SaveChanges();
            return(createDepartmententity);
        }
コード例 #6
0
        public Offering Create(Offering item)
        {
            var createOfferingentity = _context.Offerings.Add(item).Entity;

            _context.SaveChanges();
            return(createOfferingentity);
        }
コード例 #7
0
        public Organization Create(Organization item)
        {
            var createOrganizationentity = _context.Organizations.Add(item).Entity;

            _context.SaveChanges();
            return(createOrganizationentity);
        }
コード例 #8
0
        public Business Create(Business item)
        {
            var createBusinessentity = _context.Businesses.Add(item).Entity;

            _context.SaveChanges();
            return(createBusinessentity);
        }
コード例 #9
0
 public ActionResult Edit(Enterprises enterprise)
 {
     if (Request.IsAjaxRequest())
     {
         db.Entry(enterprise).State = EntityState.Modified;
         db.SaveChanges();
         return(Content("<b>Дані збережені о <b>" + DateTime.Now.ToLongTimeString()));
     }
     return(RedirectToAction("List"));
 }
コード例 #10
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,DateCreated")] Enterprise enterprise)
        {
            if (ModelState.IsValid)
            {
                db.Enterprises.Add(enterprise);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(enterprise));
        }
コード例 #11
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,EnterpriseID")] Competence competence)
        {
            if (ModelState.IsValid)
            {
                db.Competences.Add(competence);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EnterpriseID = new SelectList(db.Enterprises, "ID", "Name", competence.EnterpriseID);
            return(View(competence));
        }
コード例 #12
0
        public ActionResult Create([Bind(Include = "ID,Name,DateModified,DateCreated")] Client client)
        {
            if (ModelState.IsValid)
            {
                client.DateCreated  = DateTime.Now;
                client.DateModified = DateTime.Now;
                db.Clients.Add(client);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(client));
        }
コード例 #13
0
        public MembershipUser CreateUser(string email, string password)
        {
            MembershipUser membershipUser = GetUser(email, false);

            if (membershipUser == null)
            {
                try
                {
                    using (EnterpriseContext _db = new EnterpriseContext())
                    {
                        User user = new User();
                        user.Email        = email;
                        user.Password     = Crypto.HashPassword(password);
                        user.CreationDate = DateTime.Now;

                        if (_db.Roles.Find(2) != null)
                        {
                            user.RoleId = 2;
                        }

                        _db.Users.Add(user);
                        _db.SaveChanges();
                        membershipUser = GetUser(email, false);
                        return(membershipUser);
                    }
                }
                catch
                {
                    return(null);
                }
            }
            return(null);
        }
コード例 #14
0
        public ActionResult Create([Bind(Include = "ID,ClientID,ParentID,AccessCode,IsAndroid,ApkName,Route,Enabled,DateModified,DateCreated,DownloadCount")] Enterprise enterprise)
        {
            if (ModelState.IsValid)
            {
                // avoiding null value DateTime exception
                enterprise.DateCreated  = DateTime.Now;
                enterprise.DateModified = DateTime.Now;

                db.Enterprises.Add(enterprise);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ClientID = new SelectList(db.Clients, "ID", "Name", enterprise.ClientID);
            ViewBag.ParentID = new SelectList(db.Parents, "ID", "Name", enterprise.ParentID);
            return(View(enterprise));
        }
コード例 #15
0
        public ActionResult Create([Bind(Include = "ID,Name,Surname,Email,PhoneNr,RegistrationDate,EnterpriseID")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                int?result           = ToNullableInt32(Request.Form["CompetenceID"]);
                var competenceRating = new CompetenceRating
                {
                    CompetenceID = result,
                    EmployeeID   = employee.ID
                };
                db.CompetencesRatings.Add(competenceRating);

                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EnterpriseID = new SelectList(db.Enterprises, "ID", "Name", employee.EnterpriseID);
            return(View(employee));
        }
コード例 #16
0
        public override void CreateRole(string roleName)
        {
            Role newRole = new Role()
            {
                Name = roleName
            };
            EnterpriseContext db = new EnterpriseContext();

            db.Roles.Add(newRole);
            db.SaveChanges();
        }
コード例 #17
0
        public ActionResult Create([Bind(Include = "ID,EmployeeID,CompetenceID,Grade,DateCreated")] CompetenceRating competenceRating)
        {
            if (ModelState.IsValid)
            {
                var temp = db.CompetencesRatings.Where(e => e.EmployeeID == competenceRating.EmployeeID).FirstOrDefault();
                //if (temp != null )
                //{
                //    temp.CompetenceID = competenceRating.CompetenceID;
                //    temp.Grade = competenceRating.Grade;
                //    db.Entry(temp).State = EntityState.Modified;
                //    db.SaveChanges();
                //} else
                //{
                competenceRating.DateCreated = DateTime.Now;
                db.CompetencesRatings.Add(competenceRating);
                db.SaveChanges();
                // }
                return(RedirectToAction("Index"));
            }

            ViewBag.CompetenceID = new SelectList(db.Competences, "ID", "Name", competenceRating.CompetenceID);
            ViewBag.EmployeeID   = new SelectList(db.Employees, "ID", "Name", competenceRating.EmployeeID);
            return(View(competenceRating));
        }
コード例 #18
0
 public void Add(T entity)
 {
     _context.Set <T>().Add(entity);
     _context.SaveChanges();
 }
コード例 #19
0
        public static void EnsureSeedData(this EnterpriseContext context)
        {
            if (context.Enterprises.Any())
            {
                return;
            }

            context.Enterprises.Add(new Enterprise
            {
                Name          = "Enterprise",
                Organizations = new List <Organization>
                {
                    new Organization
                    {
                        Name      = "Organization",
                        Countries = new List <Country>
                        {
                            new Country
                            {
                                Name       = "Ukraine",
                                Businesses = new List <Business>
                                {
                                    new Business()
                                    {
                                        Name     = "GIS",
                                        Families = new List <Family>
                                        {
                                            new Family
                                            {
                                                Name      = "Cloud",
                                                Offerings = new List <Offering>
                                                {
                                                    new Offering
                                                    {
                                                        Name        = "Cloud Compute",
                                                        Departments = new List <Department>
                                                        {
                                                            new Department
                                                            {
                                                                Name  = "Department C",
                                                                Users = new List <User>
                                                                {
                                                                    new User
                                                                    {
                                                                        Name = "Ivan"
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });

            context.SaveChanges();
        }
コード例 #20
0
ファイル: EFUnitOfWork.cs プロジェクト: zholumskii/MTA
 public void Save()
 {
     db.SaveChanges();
 }