コード例 #1
0
        public RepositeryResponce Save(pos_customer customer)
        {
            int sucsess = 0;


            try
            {
                if (customer.id > 0)
                {
                    //pos_customer curentcustomer = findbyId(customer.id);
                    //dbentities.Entry(curentcustomer).CurrentValues.SetValues(customer);
                    dbentities.Entry(customer).State = EntityState.Modified;
                }
                else
                {
                    dbentities.pos_customer.Add(customer);
                }

                sucsess = dbentities.SaveChanges();
            }catch (Exception exeption)
            {
                return(new RepositeryResponce(false, CustomerConstance.SAVEERROR, null));
            }


            if (sucsess == 1)
            {
                return(new RepositeryResponce(true, CustomerConstance.SAVESUCESS, null));
            }
            else
            {
                return(new RepositeryResponce(false, CustomerConstance.SAVEERROR, null));
            }
        }
コード例 #2
0
ファイル: ItemRepo.cs プロジェクト: hmaduranga/TopUpCourwork
        public RepositeryResponce Save(pos_item item)
        {
            int sucses = 0;
            RepositeryResponce responce = new RepositeryResponce();

            try
            {
                if (item.id > 0)
                {
                    var current = dbentities.pos_item.Find(item.id);
                    dbentities.Entry(current).CurrentValues.SetValues(item);
                }
                else
                {
                    dbentities.pos_item.Add(item);
                }

                sucses = dbentities.SaveChanges();
            }
            catch (Exception exception)
            {
                responce.sucsess = false;
                responce.message = exception.Message;
                dbentities.pos_item.Remove(item);
                return(responce);
            }
            if (sucses == 1)
            {
                responce.sucsess = true;
                responce.message = CatgoryConstant.Savesucses;
                return(responce);
            }
            else
            {
                responce.sucsess = false;
                responce.message = CatgoryConstant.SaveError;
                return(responce);
            }
        }