Пример #1
0
        public ActionResult Create([Bind(Include = "Id,UserId,Title,Text,Price")] Project project, HttpPostedFileBase File)
        {
            if (ModelState.IsValid)
            {
                if (File != null && File.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(File.InputStream))
                    {
                        project.File        = reader.ReadBytes(File.ContentLength);
                        project.ContentType = File.ContentType;
                    }
                }
                else
                {
                    project.ContentType = "";
                }

                db.ProjectSet.Add(project);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.UserSet, "Id", "Name", project.UserId);
            return(View(project));
        }
Пример #2
0
        public User AddObj(User obj)
        {
            var data = db.Users.Add(obj);

            db.SaveChanges();
            return(obj);
        }
Пример #3
0
        public UMessage AddObj(UMessage obj)
        {
            var data = db.UMessages.Add(obj);

            db.SaveChanges();
            return(obj);
        }
Пример #4
0
        public Course AddObj(Course obj)
        {
            var data = db.Courses.Add(obj);

            db.SaveChanges();
            return(obj);
        }
Пример #5
0
        public Category AddObj(Category obj)
        {
            var data = db.Categories.Add(obj);

            db.SaveChanges();
            return(obj);
        }
Пример #6
0
        public Level AddObj(Level obj)
        {
            var data = db.Levels.Add(obj);

            db.SaveChanges();
            return(obj);
        }
Пример #7
0
 public IActionResult addemp(Op_Employee Op_Employee)
 {
     if (ModelState.IsValid)
     {
         _context.Employees.Add(Op_Employee);
         _context.SaveChanges();
         return(RedirectToAction("Login", "Account"));
     }
     return(View(Op_Employee));
 }
Пример #8
0
        public ActionResult Create([Bind(Include = "Id,Title")] UserType userType)
        {
            if (ModelState.IsValid)
            {
                db.UserTypeSet.Add(userType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userType));
        }
Пример #9
0
        public ActionResult Create([Bind(Include = "Id,Title,Slug")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.CategorySet.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Пример #10
0
        public ActionResult Create([Bind(Include = "Id,UserId,Amount,Date")] Payment payment)
        {
            if (ModelState.IsValid)
            {
                db.PaymentSet.Add(payment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.UserSet, "Id", "Name", payment.UserId);
            return(View(payment));
        }
Пример #11
0
        public ActionResult Create([Bind(Include = "Id,PostId,UserId,Text,Date,Verified")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.CommentSet.Add(comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.PostId = new SelectList(db.PostSet, "Id", "Title", comment.PostId);
            ViewBag.UserId = new SelectList(db.UserSet, "Id", "Name", comment.UserId);
            return(View(comment));
        }
Пример #12
0
        public ActionResult Create([Bind(Include = "Id,UserId,CategoryId,Title,Text,Date")] Post post)
        {
            if (ModelState.IsValid)
            {
                db.PostSet.Add(post);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId     = new SelectList(db.UserSet, "Id", "Name", post.UserId);
            ViewBag.CategoryId = new SelectList(db.CategorySet, "Id", "Title", post.CategoryId);
            return(View(post));
        }
Пример #13
0
 public bool AddCandidate(Op_Candidates candidate)
 {
     try
     {
         db.Candidates.Add(candidate);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
Пример #14
0
        public ActionResult Create([Bind(Include = "Id,ProjectId,UserId")] ProjectAccess projectAccess)
        {
            if (ModelState.IsValid)
            {
                db.ProjectAccessSet.Add(projectAccess);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectId = new SelectList(db.ProjectSet, "Id", "Title", projectAccess.ProjectId);
            ViewBag.UserId    = new SelectList(db.UserSet, "Id", "Name", projectAccess.UserId);
            ViewBag.Id        = new SelectList(db.PaymentSet, "Id", "Id", projectAccess.Id);
            return(View(projectAccess));
        }
 public bool AddCompanyDepartment(Lk_Company_Department companyDepartment)
 {
     try
     {
         db.CompanyDepartments.Add(companyDepartment);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
Пример #16
0
 public bool AddJob(Op_Jobs job)
 {
     try
     {
         db.Jobs.Add(job);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
 public bool AddApplication(Op_Application application)
 {
     try
     {
         db.Applications.Add(application);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
Пример #18
0
 public bool AddApplicationPhaseComment(Op_ApplicationPhaseComment apc)
 {
     try
     {
         db.ApplicationPhaseComments.Add(apc);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
Пример #19
0
 public bool AddEmployee(Op_Employee emp)
 {
     try
     {
         db.Employees.Add(emp);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
Пример #20
0
 public bool AddCompany(Lk_Company company)
 {
     try
     {
         db.Companies.Add(company);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
Пример #21
0
 public bool CreateUser(string userName, string nickname, string password, string email)
 {
     if (String.IsNullOrEmpty(userName))
     {
         throw new ArgumentException("Value cannot be null or empty.", "userName");
     }
     if (String.IsNullOrEmpty(nickname))
     {
         throw new ArgumentException("Value cannot be null or empty.", "nickname");
     }
     if (String.IsNullOrEmpty(password))
     {
         throw new ArgumentException("Value cannot be null or empty.", "password");
     }
     if (password.Length <= 4)
     {
         throw new ArgumentException("Password too short, need more than 4 chars.", "password");
     }
     if (String.IsNullOrEmpty(email))
     {
         throw new ArgumentException("Value cannot be null or empty.", "email");
     }
     if (db.UserSet.Any(u => u.Email == email))
     {
         throw new ArgumentException("This email is already registred.", "email");
     }
     if (db.UserSet.Any(u => u.Nickname == nickname))
     {
         throw new ArgumentException("This nickname is already registred.", "nickname");
     }
     try {
         var u = new TwUser();
         u.Name        = userName;
         u.Nickname    = nickname;
         u.Password    = password;
         u.Email       = email;
         u.TwitterNick = "";
         u.Token       = "";
         u.TokenSecret = "";
         db.UserSet.AddObject(u);
         db.SaveChanges();
         return(true);
     } catch (Exception e) {
         throw e;
     }
 }
Пример #22
0
        public ActionResult Create([Bind(Include = "Id,UserTypeId,Name,Mail,Password")] User user, HttpPostedFileBase Avatar)
        {
            if (ModelState.IsValid)
            {
                if (Avatar != null && Avatar.ContentLength > 0)
                {
                    using (var reader = new System.IO.BinaryReader(Avatar.InputStream))
                    {
                        user.Avatar = reader.ReadBytes(Avatar.ContentLength);
                    }
                }

                db.UserSet.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserTypeId = new SelectList(db.UserTypeSet, "Id", "Title", user.UserTypeId);
            return(View(user));
        }
 public bool AddEmployeeLoginData(Op_EmployeeLoginData eld)
 {
     try
     {
         db.EmployeeLoginDatas.Add(eld);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
 }
        public BaseController()
        {
            var user = (User)System.Web.HttpContext.Current.Session["user"];

            if (user != null)
            {
                var context = System.Web.HttpContext.Current;
                Log log     = new Log();
                log.UserId  = user.Id;
                log.Date    = DateTime.Now;
                log.Subject = context.Request.Path;
                log.Detail  = context.Request.Params.ToString();
                db.LogSet.Add(log);
                db.SaveChanges();
            }
        }
Пример #25
0
        public Tweet CreateTweet(string content, TwUser u)
        {
            if (String.IsNullOrEmpty(content))
            {
                throw new ArgumentException("Value cannot be null or empty.", "Content");
            }
            var t = new Tweet();

            t.Content     = content;
            t.TwitrucUser = u;
            t.AuthorNick  = u.TwitterNick;
            t.Date        = DateTime.Now;
            t.Sent        = false;
            t.Public      = false;
            db.TweetSet.AddObject(t);
            db.SaveChanges();
            return(t);
        }
Пример #26
0
 public TweetExtended(Twitterizer.TwitterStatus st)
 {
     using (var db = new dbContainer()) {
         try {
             Local = db.TweetSet.First(t => t.TweetId == st.Id);
         } catch (InvalidOperationException) {
             Local             = new Twitruc.DAL.Tweet();
             Local.Content     = st.Text;
             Local.AuthorNick  = st.User.ScreenName;
             Local.Date        = st.CreatedDate;
             Local.TweetId     = st.Id;
             Local.TwitrucUser = null;
             Local.Public      = !st.User.IsProtected;
             db.TweetSet.AddObject(Local);
             db.SaveChanges();
         }
         Tweeter = st;
         EndInit();
     }
 }
Пример #27
0
 public void bookinstrumet(BookInstrument obj)
 {
     obj.Approval.ToLower();
     db.BookInstruments.Add(obj);
     db.SaveChanges();
 }
Пример #28
0
        public BookInstrument ApproveBooking(BookInstrument obj)
        {
            obj.Approval.ToLower();
            obj.Instrument = db.Instruments.Find(obj.Instrument.Id);
            obj.User       = db.Users.Find(obj.User.Id);
            obj.Project    = db.Projects.Find(obj.Project.Id);
            int id = obj.Instrument.Id;
            InstrumentCondition IC = db.InstrumentConditions.Where(a => a.Instrument.Id == id).FirstOrDefault();
            var olddata            = db.BookInstruments.Find(obj.Id);

            var temp = from book in db.BookInstruments.Where(a => a.Instrument.Id == obj.Instrument.Id)

                       select new BookInstrument
            {
                From     = book.From,
                To       = book.To,
                Approval = book.Approval
            };
            bool t1    = true;
            var  temp2 = temp.ToList();

            foreach (var item in temp2)
            {
                if ((obj.From >= item.From && obj.From <= item.To) || (obj.To >= item.From && obj.To <= item.To))
                {
                    if (item.Approval == "approved")
                    {
                        t1 = false;
                        break;
                    }
                }
            }
            if (t1 == true)
            {
                olddata.From = olddata.From;
                olddata.To   = olddata.To;
                olddata.ActualWorkingHours = olddata.ActualWorkingHours;
                olddata.Approval           = "approved";
                olddata.Notes         = olddata.Notes;
                olddata.AdditionalReq = olddata.AdditionalReq;
                olddata.Instrument    = obj.Instrument;
                olddata.User          = olddata.User;
                olddata.Project       = olddata.Project;
                //IC.Condition = false;
                db.SaveChanges();
                return(obj);
            }
            else
            {
                BookInstrument i = new BookInstrument();
                return(i);
            }
        }