Exemplo n.º 1
0
        public ActionResult Team_Update([DataSourceRequest] DataSourceRequest request,
                                        [Bind(Prefix = "models")] IEnumerable <CRM_Team> listTeam)
        {
            var dbConn = Helpers.OrmliteConnection.openConn();
            IEnumerable <CRM_Team> u = new CRM_Team[] { };

            if (asset.Create)
            {
                if (listTeam != null)
                {
                    var w = new CRM_Team();
                    foreach (var team in listTeam)
                    {
                        var list = dbConn.Select <CRM_Team>(s => s.ID == team.ID).SingleOrDefault(); // CRM_Team.GetCRM_Team(team.ID);
                        list.LastUpdatedUser     = currentUser.UserName;
                        list.LastUpdatedDateTime = DateTime.Now;
                        list.TeamID   = team.TeamID;
                        list.Manager  = team.Manager;
                        list.TeamName = team.TeamName;
                        list.FKUnit   = team.FKUnit;
                        list.Active   = team.Active;
                        dbConn.Update(list);
                    }
                    return(Json(new { success = true }));
                }
                ModelState.AddModelError("", "Model not valid");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
            else
            {
                ModelState.AddModelError("", "You don't have permission to create record");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
        }
Exemplo n.º 2
0
        public ActionResult Team_Create([DataSourceRequest] DataSourceRequest request,
                                        [Bind(Prefix = "models")] IEnumerable <CRM_Team> listTeam)
        {
            var dbConn = Helpers.OrmliteConnection.openConn();
            IEnumerable <CRM_Team> u = new CRM_Team[] { };

            if (asset.Create)
            {
                if (listTeam != null)
                {
                    foreach (var team in listTeam)
                    {
                        var _team = dbConn.Select <CRM_Team>(s => s.ID == team.TeamID).SingleOrDefault(); //CRM_Team.GetCRM_Team(team.TeamID);
                        if (_team != null)
                        {
                            ModelState.AddModelError("", "TeamID is already exist: " + team.TeamID);
                            return(Json(listTeam.ToDataSourceResult(request, ModelState)));
                        }
                        var w = new CRM_Team();
                        if (w.TeamName == null)
                        {
                            w.TeamName = "";
                        }
                        w.TeamID              = team.TeamID;
                        w.Manager             = team.Manager;
                        w.TeamName            = team.TeamName;
                        w.FKUnit              = team.FKUnit;
                        w.Active              = true;
                        w.CreatedDatetime     = DateTime.Now;
                        w.CreatedUser         = currentUser.UserName;
                        w.LastUpdatedUser     = "";
                        w.LastUpdatedDateTime = DateTime.Parse("1900-01-01");
                        dbConn.Save(w);
                    }
                    return(Json(new { success = true }));
                }
                ModelState.AddModelError("", "Model not valid");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
            else
            {
                ModelState.AddModelError("", "You don't have permission to create record");
                return(Json(u.ToDataSourceResult(request, ModelState)));
            }
        }