Exemplo n.º 1
0
        // public bool DeleteResource(int catID)
        //{
        //    return ResourceDB.DeleteResource(catID);
        //}
        public int AddNewResource(Resource resource, List <Option> optlist, int userId)
        {
            int id = ResourceDB.AddNewResource(resource);

            foreach (var item in optlist)
            {
                Res_Opt_Junc res_opt = new Res_Opt_Junc();
                res_opt.Res_id = id;
                res_opt.Opt_id = item.ID;
                Res_Opt_JuncHandler rsopt = new Res_Opt_JuncHandler();
                rsopt.AddNewRes_Opt_Junc(res_opt);
            }


            ;
            if (id != 0)
            {
                var myResource =
                    ResourceDB.GetResourceList()
                    .FirstOrDefault(c => c.ID == id);
                if (myResource == null)
                {
                    return(id);
                }
                var resourceId = myResource.ID;
                common.InsertIntoUserLog(userId, "", 11, 141, "ثبت کلاس جدید", resourceId);
                return(id);
            }
            else
            {
                return(id);
            }
        }
Exemplo n.º 2
0
        public bool UpdateResource(Resource resource, List <Option> optlist, int userId)
        {
            try
            {
                foreach (var item in optlist)
                {
                    Res_Opt_Junc res_opt = new Res_Opt_Junc();
                    res_opt.Res_id   = resource.ID;
                    res_opt.Opt_id   = item.ID;
                    res_opt.IsActive = item.IsActive;
                    Res_Opt_JuncHandler rsopt = new Res_Opt_JuncHandler();
                    rsopt.UpdateRes_Opt_Junc(res_opt);
                }
            }
            catch (Exception)
            {
                throw;
            }
            var resualt = ResourceDB.UpdateResource(resource);

            return(ResourceLog(resualt, userId, resource.ID));
        }