Exemplo n.º 1
0
        public ActionResult Create(FormCollection form)
        {
            var chapters = form.AllKeys.Where(s => s.Contains("section"));
            var numChapters = chapters.Count();
            string bookName = form.GetValue("bookName").AttemptedValue;

            var book = new Book { BookID = bookName, AgeGroup = (AgeGroups)Enum.Parse(typeof(AgeGroups), form.GetValue("ageGroup").AttemptedValue, true) };
            db.Books.Add(book);

            var counter = 1;
            foreach (var chapter in chapters)
            {
                var dbChapter = new Chapter { BookID = book.BookID, ChapterID = counter++ };
                db.Chapters.Add(dbChapter);

                int numSections = int.Parse(form.GetValue(chapter).AttemptedValue);
                for (int i = 0; i < numSections; i++)
                {
                    db.Sections.Add(new Section { ChapterID = dbChapter.ChapterID, BookID = dbChapter.BookID, SectionID = i + 1 });
                }
            }
            db.SaveChanges();

            return RedirectToAction("Index");
        }
Exemplo n.º 2
0
        public ActionResult Edit(int id, FormCollection forms)
        {
            if (id == 0)
            {
                CmsMenu newMenu = new CmsMenu()
                                   {
                                       Title = forms.GetValue("Title").AttemptedValue,
                                       Description = forms.GetValue("Description").AttemptedValue,
                                       Type = forms.GetValue("Type").AttemptedValue
                                   };
                if (newMenu.IsValid)
                {
                    return this.CreateNewMenu(newMenu);
                }

                ModelState.AddModelErrors(newMenu.GetRuleViolations());
                return View(newMenu);
            }

            CmsMenu menu = this.menuService.LoadMenu(id);
            UpdateModel(menu, forms.ToValueProvider());
            this.menuService.SaveMenu(menu);
            TempData["SuccessResult"] = "Menu was successfully saved";
            return this.View(menu);
        }
Exemplo n.º 3
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                NHibernateHelper nhibernateHelper = new NHibernateHelper(@"fluentData.db");
                using(ISessionFactory sessionFactory = nhibernateHelper.GetSessionFactory())
                {
                    using (ISession session = sessionFactory.OpenSession())
                    {
                        using (ITransaction transaction = session.BeginTransaction())
                        {
                            var company = new Company
                            {
                                OrganizationNumber = collection.GetValue("OrganizationNumber").AttemptedValue,
                                Name = collection.GetValue("Name").AttemptedValue
                            };

                            session.SaveOrUpdate(company);

                            transaction.Commit();

                            //collection.Set("Id", company.Id.ToString());

                            return RedirectToAction("Edit", new { id = company.Id });
                        }
                    }
                }

            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 4
0
 public JsonResult Progress(FormCollection Fm)
 {
     //todo 通过cookie获得用户关联到项目
     //todo 根据后台可编辑时间确定是否接收
     var _sequence = int.Parse(Fm.GetValue("sequence").AttemptedValue);
     var _title = Fm.GetValue("title").AttemptedValue;
     var _content = Fm.GetValue("content").AttemptedValue;
     DBHelper.instence.Project_progress.AddOrUpdate(new Project_Progress { sequence = _sequence, title = _title, content = _content });
     if(DBHelper.instence.SaveChanges()>0)
         return new JsonResult
         {
             Data = new
             {
                 message = "项目第"+ _sequence + "次记录保存成功!"
             }
         };
     else
         return new JsonResult
         {
             Data = new
             {
                 message = "提交失败!"
             }
         };
 }
        public TransactionsFilter(FormCollection formCollection)
        {
            Years = int.Parse(GetValue(formCollection.GetValue("Years")));
            Months = int.Parse(GetValue(formCollection.GetValue("Months")));

            PaymentMethods = GetValue(formCollection.GetValue(PAYMENT_METHODS_ID));

            InitPaymentMethodsList(GetValue(formCollection.GetValue(PAYMENT_METHODS_ID)));
        }
Exemplo n.º 6
0
 public ActionResult AdditionalDetails(FormCollection form)
 {
     EnquiryDetails details = new EnquiryDetails();
        details.Amount = Convert.ToDouble(form.GetValue("amount").AttemptedValue);
        details.FileName = form.GetValue("uploadpath").AttemptedValue.ToString();
        details.UniqueName = form.GetValue("savedName").AttemptedValue.ToString();
        details.EnquiryID = Convert.ToInt32(TempData["EnquiryId"]);
        enquiryDetailsRepository.InsertOrUpdate(details);
        enquiryDetailsRepository.Save();
        return RedirectToAction("Details", new { id = details.EnquiryID });
 }
Exemplo n.º 7
0
 public ActionResult Index(FormCollection collection)
 {
     DateTime startDate = Convert.ToDateTime(collection.GetValue("todate").AttemptedValue).Date;
     DateTime endDate = Convert.ToDateTime(collection.GetValue("fromdate").AttemptedValue).Date;
     JiraPresenter jiraPresenter = new JiraPresenter();
     List<JiraTimeSheet> jiraTimeSheetList = jiraPresenter.ProcessIssues(startDate, endDate);
     ViewBag.startdate = startDate;
     ViewBag.enddate = endDate;
     ViewBag.title = "Displaying " + jiraTimeSheetList.Count + " issues at " + DateTime.Now + " from "+ startDate.Date + " to " + endDate.Date;
     return View("WorkLogs", jiraTimeSheetList);
 }
Exemplo n.º 8
0
 public ActionResult Create(FormCollection collection)
 {
     _repository.AddMovie(collection.GetValue("Title").ToString(), collection.GetValue("Genre").ToString());
     try
     {
         // TODO: Add insert logic here
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 9
0
        public ActionResult AdminDeviceSearch(FormCollection collection)
        {
            #region Get Search Query

            string query = collection.GetValue("query").AttemptedValue;

            #endregion

            #region Prep Utilities

            BusinessLogicHandler myHandler = new BusinessLogicHandler();
            SearchViewModel model = new SearchViewModel();

            #endregion

            #region Execute Search

            model.Query = query;
            model.GadgetResults = myHandler.TechnologyGlobalSearch(query);
            model.GadgetCategoryResults = myHandler.DeviceGlobalSearch(query);
            model.ManufacturerResults = myHandler.ManufacturerGlobalSearch(query);

            #endregion

            return View(model);
        }
Exemplo n.º 10
0
        public ActionResult AdminBookSearch(FormCollection collection)
        {
            #region Get Search Query

            string query = collection.GetValue("query").AttemptedValue;

            #endregion

            #region Prep Utilities

            BusinessLogicHandler myHandler = new BusinessLogicHandler();
            SearchViewModel model = new SearchViewModel();

            #endregion

            #region Execute Search

            model.Query = query;
            model.BookResults = myHandler.BookGlobalSearch(query);
            model.BookCategoryResults = myHandler.BookCategoryGlobalSearch(query);
            model.AuthorResults = myHandler.AuthorGlobalSearch(query);
            model.PublisherResults = myHandler.PublisherGlobalSearch(query);

            #endregion

            return View(model);
        }
Exemplo n.º 11
0
        public ActionResult AddApplicationSubscription(Subscription record, FormCollection form)
        {
            try
            {
                record.Type = "Application";
                record.CreatedDate = DateTime.Now;
                record.State = "Active";

                var application_ = form.GetValue("application_");
                if ((application_ != null) && (application_.AttemptedValue != null))
                {
                    int applicationId = Int32.Parse(application_.AttemptedValue);
                    SubscriptionItem item = new SubscriptionItem();
                    item.ApplicationId = applicationId;
                    record.Items = new List<SubscriptionItem>();
                    record.Items.Add(item);
                }

                CcAddSubscriptionRequest request = new CcAddSubscriptionRequest(Settings.Credentials);
                request.Subscription = record;
                EndPoints.CcDashboardService.AddSubscription(request);
                return RedirectToAction("Subscriptions");
            }
            catch (Exception e)
            {
                return ShowError(e);
            }
        }
Exemplo n.º 12
0
        public ActionResult Create(FormCollection collection)
        {
            if (collection.Count != 0)
            {
                BarometerDataAccesLayer.DatabaseClassesDataContext context = DatabaseFactory.getInstance().getDataContext();
                BarometerDataAccesLayer.Project insertProject = new BarometerDataAccesLayer.Project();
                BarometerDataAccesLayer.ProjectOwner me = new BarometerDataAccesLayer.ProjectOwner();
                var ownerInfo =
                    from u in context.Users
                    where u.student_number == CurrentUser.getInstance().Studentnummer
                    select u;
                me.User = ownerInfo.First();
                insertProject.name = collection.GetValue("FormProject.name").AttemptedValue;
                insertProject.description = collection.GetValue("FormProject.description").AttemptedValue;
                insertProject.start_date = DateTime.ParseExact(collection.GetValue("FormProject.start_date").AttemptedValue, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                insertProject.end_date = DateTime.ParseExact(collection.GetValue("FormProject.end_date").AttemptedValue, "dd-MM-yyyy", CultureInfo.InvariantCulture);
                insertProject.ProjectOwners.Add(me);
                insertProject.status_name = "Pending";
                if (Request.Files.Count != 0)
                {
                    HttpPostedFileBase fileBase = Request.Files[0];
                    StudentExcel studentExcel = new StudentExcel(insertProject);
                    studentExcel.Import(fileBase.InputStream);

                    insertProject.baro_template_id = int.Parse(collection.GetValue("FormProject.baro_template_id").AttemptedValue);

                    string[] reportDateNames = collection.GetValue("reportDateName[]").AttemptedValue.Split(',');
                    string[] reportStartDates = collection.GetValue("reportStartDate[]").AttemptedValue.Split(',');
                    string[] reportEndDates = collection.GetValue("reportEndDate[]").AttemptedValue.Split(',');
                    EntitySet<BarometerDataAccesLayer.ProjectReportDate> reportDateEntities = new EntitySet<BarometerDataAccesLayer.ProjectReportDate>();

                    int counter = 0;
                    foreach (string reportDateName in reportDateNames)
                    {
                        BarometerDataAccesLayer.ProjectReportDate tmpReportDate = new BarometerDataAccesLayer.ProjectReportDate();
                        tmpReportDate.Project = insertProject;
                        tmpReportDate.week_label = reportDateName;
                        tmpReportDate.start_date = DateTime.Parse(reportStartDates[counter]);
                        tmpReportDate.end_date = DateTime.Parse(reportEndDates[counter]);
                        context.ProjectReportDates.InsertOnSubmit(tmpReportDate);
                        counter++;
                    }
                    context.SubmitChanges();
                }
            }
            return RedirectToAction("List");
        }
Exemplo n.º 13
0
        public ActionResult BulkCreate(FormCollection formdata)
        {
            var InboundMasterID = Convert.ToInt32(((string[])(formdata.GetValue("InboundMasterID").RawValue))[0]);
            var addedBooks = new List<InboundBook>();
            if (ModelState.IsValid)
            {
                for (int i = 0; i < 10; i++)
                {
                    var noOfBooks = ((string[])(formdata.GetValue("item.NumberOfBooks").RawValue))[i];
                    if (!string.IsNullOrWhiteSpace(noOfBooks))
                    {

                        addedBooks.Add(new InboundBook
                        {
                            NumberOfBooks = Convert.ToInt32(noOfBooks),
                            BookID= Convert.ToInt32(((string[])(formdata.GetValue("BookID").RawValue))[i])

                        });
                    }
                }
                var groupedData = addedBooks.GroupBy(o => o.BookID).
                    Select(grp => new InboundBook { BookID = grp.Key, InboundMasterID = InboundMasterID, NumberOfBooks = grp.Sum(o => o.NumberOfBooks) });

                //    //var matchedItem = db.DistributedBooks.Where(o => o.EventID == distributedbook.EventID && o.BookID == distributedbook.BookID);
                //    //if (matchedItem.Count() > 1)
                //    //{
                //    //    throw new Exception("Invalid Data");
                //    //}
                //    //else if (matchedItem.Count() == 1)
                //    //{
                //    //    var item = matchedItem.SingleOrDefault();
                //    //    item.NumberOfBooks = item.NumberOfBooks + distributedbook.NumberOfBooks;
                //    //    db.Entry(item).State = EntityState.Modified;

                //    //}
                foreach (var item in groupedData)
                {

                    AddDistributedBook(item);
                }
                db.SaveChanges();
                return RedirectToAction("Index", new { InboundMasterID });

            }
            else
                return RedirectToAction("ValidationError", "Error", new { errorMesage = "Error occured while doing bulk update" });
        }
Exemplo n.º 14
0
        public ActionResult Create(CreateModuleViewModel _model, FormCollection collector)
        {
            BusinessLogicHandler _gateWay = new BusinessLogicHandler();
            Module _module = new Module();
            _module.ModuleCode = _model.ModuleCode;
            _module.ModuleName = _model.ModuleName;
            _module.NumberOfScheduledClasses = _model.NumberOfScheduledClasses;
            _module.QualificationCode = Convert.ToInt32(collector.GetValue("Qualifications").AttemptedValue);

            try
            {

                if(_gateWay.InsertModule(_module))
                { return RedirectToAction("Index");/*CHANGE THIS HERE*/ }
                else
                {

                    #region Load Dropdown

                    List<Qualification> _qualifications = new List<Qualification>();
                    _qualifications = _gateWay.GetQualifications();

                    List<SelectListItem> _qualList = new List<SelectListItem>();

                    foreach (var _qualification in _qualifications)
                    {
                        _qualList.Add(new SelectListItem { Text = _qualification.QualificationName, Value = _qualification.QualificationCode.ToString() });
                    }
                    ViewData["Qualifications"] = _qualList;
                    _model.Qualifications = _qualList;

                    #endregion

                    return View(_model);
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("" + ex.Source, ex);

                #region Load Dropdown

                List<Qualification> _qualifications = new List<Qualification>();
                _qualifications = _gateWay.GetQualifications();

                List<SelectListItem> _qualList = new List<SelectListItem>();

                foreach (var _qualification in _qualifications)
                {
                    _qualList.Add(new SelectListItem { Text = _qualification.QualificationName, Value = _qualification.QualificationCode.ToString() });
                }
                ViewData["Qualifications"] = _qualList;
                _model.Qualifications = _qualList;

                #endregion

                return View(_model);
            }
        }
Exemplo n.º 15
0
 public JsonResult Drop(FormCollection form)
 {
     var planId = 0;
     if (!int.TryParse(form.GetValue("plan-id").AttemptedValue, out planId)) return Json(null);
     var result = db.Plans.Delete(planId);
     db.SaveChanges();
     return Json(result);
 }
        public ActionResult Calculate(FormCollection collection)
        {
            try
            {
                var a = (int)collection.GetValue("a").ConvertTo(typeof(int));
                var b = (int)collection.GetValue("b").ConvertTo(typeof(int));
                ViewBag.result = a + b;

                return this.View("index");
            }
            catch (Exception)
            {
                ViewBag.error = @"Both 'a' and 'b' are mandatory and must be numbers!";
                return this.View("index");
            }
            
        }
Exemplo n.º 17
0
        public ActionResult RegisterMatch(FormCollection formCollection)
        {
            var currentUser = (Player)Session["User"];

            if (currentUser != null)
            {
                var teamAScore = formCollection.GetValue("team-a-score").AttemptedValue;
                var teamBScore = formCollection.GetValue("team-b-score").AttemptedValue;
                var newMatch = MatchControllerHelpers.CreateMatch(currentUser, formCollection);

                // Get the scores
                newMatch.TeamAScore = int.Parse(teamAScore, NumberStyles.Float);
                newMatch.TeamBScore = int.Parse(teamBScore, NumberStyles.Float);
                newMatch.ResolveMatch().SaveMatch();
            }

            return this.RedirectToAction("Index");
        }
Exemplo n.º 18
0
        public ActionResult Create(Lecture _lecture, FormCollection collector)
        {
            BusinessLogicHandler _gateWay = new BusinessLogicHandler();

            #region Identity

            ApplicationDbContext dataSocket = new ApplicationDbContext();
            UserStore<ApplicationUser> myStore = new UserStore<ApplicationUser>(dataSocket);
            UserManager = new ApplicationUserManager(myStore);
            var user = UserManager.FindByName(HttpContext.User.Identity.Name);

            #endregion

            #region Get Lecturer
            //Lecturer staffMember = new Lecturer();
            //staffMember = _gateWay.GetLecturer(user.Id);
            #endregion

            #region Setting things up
            try
            {
                string[] dateSlice = collector.GetValue("dateHoldhidden").AttemptedValue.Split(' ');
                string timeSlice = collector.GetValue("timeHoldhidden").AttemptedValue;
                _lecture.TimeSlot = dateSlice[0] + " " + timeSlice;
            }
            catch
            {
                return View(_lecture);
            }

            #endregion
            try
            {
                if(_gateWay.InsertLecture(_lecture))
                { return RedirectToAction("Index");}
                else
                { return View(_lecture); }
            }
            catch
            {
                return View(_lecture);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Adds menu items to root node
        /// </summary>
        /// <param name="n"></param>
        /// <param name="queryStrings"></param>
        protected virtual void AddMenuItemsToRootNode(TreeNode n, FormCollection queryStrings)
        {
            if (!queryStrings.GetValue<bool>(TreeQueryStringParameters.DialogMode))
            {
                //add some menu items to the created root node
                n.AddEditorMenuItem<CreateItem>(this, "createUrl", "Create");
                n.AddMenuItem<Reload>();
            }

        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Usuario user = new Usuario();
                user.Matricula = collection.GetValue("Matricula").AttemptedValue;
                user.Nome = collection.GetValue("Nome").AttemptedValue;
                user.Setor = collection.GetValue("Setor").AttemptedValue;
                user.Cargo = collection.GetValue("Cargo").AttemptedValue;

                _service.CreateUsuario(user);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 21
0
        public void GetValue_ThrowsIfNameIsNull() {
            // Arrange
            FormCollection formCollection = new FormCollection();

            // Act & assert
            ExceptionHelper.ExpectArgumentNullException(
                delegate {
                    formCollection.GetValue(null);
                }, "name");
        }
Exemplo n.º 22
0
 public ActionResult StudentForm(FormCollection collection)
 {
     int studentNumber = int.Parse(collection.GetValue("student").AttemptedValue);
     BarometerDataAccesLayer.DatabaseClassesDataContext context = DatabaseFactory.getInstance().getDataContext();
     var student =
         from u in context.Users
         where u.student_number == studentNumber
         select u.id;
     int studentId = student.First();
     return RedirectToAction("Student","Admin", new { studentId = studentId });
 }
Exemplo n.º 23
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Livro livro = new Livro();
                livro.Nome = collection.GetValue("Nome").AttemptedValue;
                livro.Preco = Convert.ToDouble(collection.GetValue("Preco").AttemptedValue);
                livro.Descricao = collection.GetValue("Descricao").AttemptedValue;

                Autor autor = new Autor();
                livro.AutorId = Convert.ToInt32(collection.GetValue("AutorId").AttemptedValue); ;
                livro.Autor= autor;
                _repository.Save(livro);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                Movie movie = new Movie();
                movie.Inventory = int.Parse(collection.GetValue("Inventory").AttemptedValue.ToString());
                movie.Overview = collection.GetValue("Overview").AttemptedValue.ToString();
                movie.ReleaseDate = collection.GetValue("ReleaseDate").AttemptedValue.ToString();
                movie.Title = collection.GetValue("Title").AttemptedValue.ToString();

                MovieRepository r = new MovieRepository();
                r.Add(movie);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 25
0
 public JsonResult Drop(FormCollection form)
 {
     int id = 0;
     if (int.TryParse(form.GetValue("lesson-id").AttemptedValue, out id))
     {
         var result = _db.Lessons.Delete(id);
         _db.SaveChanges();
         return Json(result.TimeString);
     }
     return Json(false);
 }
Exemplo n.º 26
0
        public ActionResult AddStudent(FormCollection collection)
        {
            int studentIdToAdd = int.Parse(collection.GetValue("student").AttemptedValue);
            int projectId = int.Parse(collection.GetValue("projectID").AttemptedValue);
            int groupId = int.Parse(collection.GetValue("groupID").AttemptedValue);
            DAOStudent studentdao = DatabaseFactory.getInstance().getDAOStudent();
            DAOProject projectdao = DatabaseFactory.getInstance().getDAOProject();
            BarometerDataAccesLayer.User studentUser = studentdao.getStudentInfo(studentIdToAdd);
            IEnumerable<BarometerDataAccesLayer.ProjectMember> member = studentUser.ProjectMembers.Where(pm => pm.project_group_id == groupId);
            if (member.Count() == 0)
            {
                BarometerDataAccesLayer.ProjectMember pMember = new BarometerDataAccesLayer.ProjectMember();
                pMember.User = studentUser;
                pMember.project_group_id = groupId;
                BarometerDataAccesLayer.DatabaseClassesDataContext context = DatabaseFactory.getInstance().getDataContext();
                context.ProjectMembers.InsertOnSubmit(pMember);
                context.SubmitChanges();
            }

            return RedirectToAction("ProjectGroups", new { groupId = groupId });
        }
Exemplo n.º 27
0
        public ActionResult CreateRanks(PERSON rank, FormCollection collection)
        {
            try
            {

                var f = collection.GetValue("chair");
                string chair = f.AttemptedValue.ToString();
                var au = collection.GetValue("degree");
                string degree = au.AttemptedValue.ToString();

                if(ModelState.IsValid)
                {
                    string n = rank.PR_NAME;
                    if((from c in ctx.PERSON where c.PR_NAME == n select c).Any())
                    {
                        return RedirectToAction("Problem");
                    }
                    else
                    {
                        var ch = (from c in ctx.DIC_CHAIRS where c.DCH_NAME == chair select c).First();
                        var dg = (from c in ctx.DIC_DEGREE where c.DDG_NAME == degree select c).First();
                        rank.PR_DDG = dg.DDG_ID;
                        rank.PR_DCH = ch.DCH_ID;
                        rank.DIC_CHAIRS = ch;

                        ctx.PERSON.Add(rank);
                        ctx.SaveChanges();

                    }
                }

                return RedirectToAction("AllPeople");

            }
            catch
            {
                return RedirectToAction("Problem");
            }
            return View();
        }
Exemplo n.º 28
0
        public ActionResult Assign(FormCollection col)
        {
            int enquiryId = Convert.ToInt32(col.GetValue("Enquiry").AttemptedValue);
            int projectId = Convert.ToInt32(col.GetValue("Project").AttemptedValue);
            int TeamType = Convert.ToInt32(col.GetValue("TeamType").AttemptedValue);
            string TeamTypeName = (TeamType==1)?"Non Kenwood Team":"Kenwood Team";
            string TeamName = String.Empty;
            if(TeamType==1)
            {
                TeamName = col.GetValue("Non_Kenwood").AttemptedValue.ToString();

            }
            else{

                 TeamName = teamRepository.Find(Convert.ToInt32(col.GetValue("Team").AttemptedValue)).TeamName;
            }
            TeamProject team = new TeamProject();
            team.ProjectID = projectId;
            team.TeamID = Convert.ToInt32(col.GetValue("Team").AttemptedValue);
            BusinessFlowContext context = new BusinessFlowContext();
            context.TeamProjects.Add(team);
            context.SaveChanges();

            return RedirectToAction("TeamAssigned",team);
        }
Exemplo n.º 29
0
        public ActionResult Create(T_JG_Product t_jg_product, FormCollection collection)
        {
            if (ModelState.IsValid)
            {
                if (collection.GetValue("checkboxType") != null)
                {
                    string strType = collection.GetValue("checkboxType").AttemptedValue;
                    t_jg_product.CustomerType = strType;
                }
                t_jg_product.AgencyID = GetAgencyIDbyMemberID((int)Session["MemberID"]);
                t_jg_product.IsValid = true;
                t_jg_product.OP = 0;
                t_jg_product.CreateTime = DateTime.Now;
                t_jg_product.UpdateTime = DateTime.Now;
                t_jg_product.Member = CurrentMember();
                HttpPostedFileBase file = Request.Files[0];
                //存入文件
                if (file.ContentLength > 0)
                {
                    t_jg_product.Pic = new byte[Request.Files[0].InputStream.Length];
                    Request.Files[0].InputStream.Read(t_jg_product.Pic, 0, t_jg_product.Pic.Length);
                }

                db.T_JG_Product.Add(t_jg_product);
                int result = db.SaveChanges();
                if (result > 0)
                {
                    Logging("发布了新的产品", (int)OperateTypes.Create, (int)GenerateSystem.Publish);
                    return RedirectToAction("Create", new { notice_type = "success" });
                }
                else
                {
                    LoggingError((int)LogLevels.warn, "金融产品发布失败", (int)OperateTypes.Create, (int)GenerateTypes.FromMember, (int)GenerateSystem.Publish);
                    ViewData["error"] = "金融产品发布失败!请检查输入信息或联系我们!";
                    return View(t_jg_product);
                }
            }
            ViewData["error"] = "金融产品发布失败!请检查输入信息或联系我们!";
            return View(t_jg_product);
        }
Exemplo n.º 30
0
        public ActionResult CreateRanks(PERSON_RANKS rank, FormCollection collection)
        {
            try
            {

                var f = collection.GetValue("head");
                string head = f.AttemptedValue.ToString();
                var au = collection.GetValue("rank");
                string audi = au.AttemptedValue.ToString();

                if ((from c in ctx.PERSON_RANKS where c.PERSON.PR_NAME == head && c.DIC_RANKS.DRK_NAME == audi select c).Any())
                {
                    return RedirectToAction("AllRelations");
                }
                else
                {
                    var person = (from c in ctx.PERSON where c.PR_NAME == head select c).First();
                    var audience = (from c in ctx.DIC_RANKS where c.DRK_NAME == audi select c).First();

                    PERSON_RANKS rel = new PERSON_RANKS();

                    rel.PERSON = person;
                    rel.DIC_RANKS = audience;

                    ctx.PERSON_RANKS.Add(rel);
                    ctx.SaveChanges();

                }

                return RedirectToAction("AllRelations");

            }
            catch
            {
                return RedirectToAction("Problem");
            }
            return View();
        }
Exemplo n.º 31
0
        public ActionResult ChangeRole(User user, FormCollection collection)
        {
            var currentUser = User as ApplicationUser;

            var currentRole  = Request.Form["CurrentRole"];                 //the id
            var roleToChange = collection.GetValue("Roles").AttemptedValue; //new role id

            if (currentRole.Equals(roleToChange, StringComparison.InvariantCultureIgnoreCase))
            {
                return(RedirectToAction("Index", "User"));
            }

            _userUILogic.ChangeRoleUser(user.Id, roleToChange, user.Email, currentUser);
            return(RedirectToAction("Index", "User"));
        }
Exemplo n.º 32
0
        public ActionResult InviteUser(User newUser, FormCollection collection)
        {
            var userLogin = User as ApplicationUser;

            try
            {
                var band = _userUILogic.NotFoundUserWithEmail(newUser.Email);

                if (band)
                {
                    var currentTenancy = TenantManager.CurrentTenancy;
                    if (currentTenancy.Equals(Tenants.SuperAdmin, StringComparison.OrdinalIgnoreCase))
                    {
                        //It should create a tenant
                        var tenantToInvite = collection.GetValue("selectedTenant").AttemptedValue.Split('/').Last();
                        _userUILogic.SendInvitation(newUser, tenantToInvite, currentTenancy, Request.Url, userLogin);
                    }

                    else
                    {
                        _userUILogic.SendInvitation(newUser, currentTenancy, Request.Url, userLogin);
                    }

                    var toUrl = Request.UrlReferrer;
                    if (toUrl != null)
                    {
                        return(Redirect(toUrl.AbsoluteUri));
                    }
                }

                TempData.Add("CurrentInvite", newUser);
                TempData.Add("MessageError", "Email already invited, try with another email");

                ModelState.AddModelError("Email", "Email already invited, try with another email");
                return(RedirectToAction("Index", new { reload = true }));
            }

            catch (Exception ex)
            {
                ExceptionHandler.Manage(ex, this, Layer.UILogic);

                if (ex.InnerException != null)
                {
                    _log.ErrorFormat("{0} \n InnerException: {1}", ex, ex.InnerException);
                }
                else if (userLogin != null)
                {
                    _log.ErrorFormat(
                        "Current User: {0} - An exception occurred with the following message: {1}",
                        userLogin.UserName,
                        ex.Message);
                }

                const string smtpExceptionMessage = "Failure to send the email, please check the SMTP configuration";
                TempData.Remove("MessageError");
                TempData.Add("MessageError", smtpExceptionMessage);

                TempData.Remove("CurrentInvite");
                TempData.Add("CurrentInvite", newUser);

                return(RedirectToAction("Index", new { reload = true }));
            }
        }