Esempio n. 1
0
        public virtual ActionResult CreateProject(ProjectView created)
        {
            var startnode = _entities.FlowSteps.SingleOrDefault(x => x.FlowType ==2 && x.StepType == 0);

            if (ModelState.IsValid)
            {
                var newlayout = created.ToModel();
                newlayout.FlowState = startnode.StepID;
                var js = " $('.info_div').hide();$('#success').fadeIn('slow');";
                try
                {
                    _entities.DgProjects.AddObject(newlayout);
                    _entities.SaveChanges();
                    var log = new FlowLog
                    {
                        ProjectId = newlayout.ProjectId,
                        Startdate = DateTime.Now,
                        ActiveFlag = true,
                        ToDoby =
                            _entities.Users.SingleOrDefault(
                                x => x.UserName.Trim() == User.Identity.Name.Trim()).UserID,
                        LogStep = startnode.StepID
                    };
                    _entities.FlowLogs.AddObject(log);
                    _entities.SaveChanges();
                    return JavaScript(js);
                }
                catch
                {
                    js = " $('.info_div').hide();$('#fail').fadeIn('slow');";
                    return JavaScript(js);
                }
            }
            return JavaScript(" $('.info_div').hide(); $('#warning').fadeIn('slow');");
        }