예제 #1
0
        /// <summary>
        /// dohvati jedan po primary key-u
        /// </summary>
        /// <param name="guid"></param>
        /// <returns></returns>
        public CvCompetences Get(int Id)
        {
            CvCompetences item = null;

            using (Entities data = new Entities())
            {
                item = data.CvCompetences.Where(r => r.Id == Id).FirstOrDefault();
            }

            return(item);
        }
예제 #2
0
        /// <summary>
        /// obriši item
        /// nije brisanje već postavljanje Deleted polja na true
        /// </summary>
        /// <param name="item">instanca entity objekta</param>
        /// <returns></returns>
        public bool Delete(CvCompetences item)
        {
            bool uspjelo = false;

            using (KaFotkaEntities data = new KaFotkaEntities())
            {
                item.Deleted = true;
                data.Entry <CvCompetences>(item).State = System.Data.EntityState.Modified;
                data.SaveChanges();

                uspjelo = true;
            }

            return(uspjelo);
        }
예제 #3
0
        /// <summary>
        /// spremi item
        /// insert ako nema Id
        /// update ako ima Id
        /// </summary>
        /// <param name="item">instanca entity objekta</param>
        /// <returns></returns>
        public bool Save(CvCompetences item)
        {
            bool uspjelo = false;

            using (Entities data = new Entities())
            {
                data.CvCompetences.Add(item);
                //ako ima Id onda je update
                if (item.Id != null)
                {
                    data.Entry <CvCompetences>(item).State = System.Data.EntityState.Modified;
                }

                data.SaveChanges();

                uspjelo = true;
            }

            return(uspjelo);
        }