Beispiel #1
0
        public Models.Rate Create(Models.Rate entity)
        {
            try
            {
                entity = RateDataProccessor.ValidationAndProcess(entity);

                if (((new RestfulModels.Rate()).Search(new Models.RateSearchModel()
                {
                    ReviewId = entity.ReviewId, AspectId = entity.AspectId, Creator = entity.Creator
                })).Count() > 0)
                {
                    var e = new RestfulModels.ValidationException();
                    e.ValidationErrors.Add("已经存在");

                    throw e;
                }

                DbEntities.Rates.AddObject(entity);
                DbEntities.SaveChanges();
                DbEntities.Refresh(System.Data.Objects.RefreshMode.StoreWins, entity);

                return(entity);
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
        public Models.Rate Update(int id, Models.Rate entity)
        {
            try
            {
                entity    = RateDataProccessor.ValidationAndProcess(entity);
                entity.Id = id;

                DbEntities.ApplyCurrentValues("Rates", entity);
                DbEntities.SaveChanges();

                return(Read(entity.Id));
            }
            catch
            {
                throw;
            }
        }