// PUT: odata/BenthicEventConditions(5) public IHttpActionResult Put([FromODataUri] int key, Delta <BenthicEventCondition> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BenthicEventCondition benthicEventCondition = db.BenthicEventConditions.Find(key); if (benthicEventCondition == null) { return(NotFound()); } BenthicEvent @BenthicEvent = db.BenthicEvents.Find(benthicEventCondition.Id); var check = AuthorizeLogic.VerifyBenthicEventEditPermission(@BenthicEvent); if (check) { patch.Put(benthicEventCondition); try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BenthicEventConditionExists(key)) { return(NotFound()); } else { throw; } } return(Updated(benthicEventCondition)); } else { return(Unauthorized()); } }
// PUT: odata/Samples(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <Sample> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Sample sample = await db.Samples.FindAsync(key); if (sample == null) { return(NotFound()); } Event @event = db.Events.Find(sample.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { patch.Put(sample); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SampleExists(key)) { return(NotFound()); } else { throw; } } return(Updated(sample)); } else { return(Unauthorized()); } }
// PUT: odata/Groups(5) public async Task <IHttpActionResult> Put([FromODataUri] int key, Delta <Group> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Group group = await db.Groups.FindAsync(key); if (group == null) { return(NotFound()); } var check = AuthorizeLogic.VerifyGroupEditPermission(group); if (check) { patch.Put(group); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupExists(key)) { return(NotFound()); } else { throw; } } return(Updated(group)); } else { return(Unauthorized()); } }
// POST[Authorize]: odata/Groups public async Task <IHttpActionResult> Post(Group group) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var check = AuthorizeLogic.VerifyGroupEditPermission(group); if (check) { db.Groups.Add(group); await db.SaveChangesAsync(); return(Created(group)); } else { return(Unauthorized()); } }
// POST: odata/BenthicSamples public IHttpActionResult Post(BenthicSample benthicSample) { if (!ModelState.IsValid) { return BadRequest(ModelState); } BenthicEvent @BenthicEvent = db.BenthicEvents.Find(benthicSample.BenthicEventId); var check = AuthorizeLogic.VerifyBenthicEventEditPermission(@BenthicEvent); if (check) { db.BenthicSamples.Add(benthicSample); db.SaveChanges(); return Created(benthicSample); } else { return Unauthorized(); } }
// POST: odata/EventConditions public IHttpActionResult Post(EventCondition eventCondition) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Event @event = db.Events.Find(eventCondition.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { db.EventConditions.Add(eventCondition); db.SaveChanges(); return(Created(eventCondition)); } else { return(Unauthorized()); } }
// POST: odata/Samples public async Task <IHttpActionResult> Post(Sample sample) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Event @event = db.Events.Find(sample.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { db.Samples.Add(sample); await db.SaveChangesAsync(); return(Created(sample)); } else { return(Unauthorized()); } }
// POST: odata/BenthicEvents public IHttpActionResult Post(BenthicEvent benthicEvent) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var check = AuthorizeLogic.VerifyBenthicEventEditPermission(benthicEvent); if (check) { db.BenthicEvents.Add(benthicEvent); db.SaveChanges(); return(Created(benthicEvent)); } else { return(Unauthorized()); } }
// DELETE: odata/BenthicSamples(5) public IHttpActionResult Delete([FromODataUri] int key) { BenthicSample benthicSample = db.BenthicSamples.Find(key); if (benthicSample == null) { return NotFound(); } BenthicEvent @BenthicEvent = db.BenthicEvents.Find(benthicSample.BenthicEventId); var check = AuthorizeLogic.VerifyBenthicEventEditPermission(@BenthicEvent); if (check) { db.BenthicSamples.Remove(benthicSample); db.SaveChanges(); return StatusCode(HttpStatusCode.NoContent); } else { return Unauthorized(); } }
// DELETE: odata/Groups(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { Group group = await db.Groups.FindAsync(key); if (group == null) { return(NotFound()); } var check = AuthorizeLogic.VerifyGroupEditPermission(group); if (check) { db.Groups.Remove(group); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); } else { return(Unauthorized()); } }
// DELETE: odata/Samples(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { Sample sample = await db.Samples.FindAsync(key); if (sample == null) { return(NotFound()); } Event @event = db.Events.Find(sample.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { db.Samples.Remove(sample); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); } else { return(Unauthorized()); } }
// DELETE: odata/EventConditions(5) public IHttpActionResult Delete([FromODataUri] int key) { EventCondition eventCondition = db.EventConditions.Find(key); if (eventCondition == null) { return(NotFound()); } Event @event = db.Events.Find(eventCondition.EventId); var check = AuthorizeLogic.VerifyEventEditPermission(@event); if (check) { db.EventConditions.Remove(eventCondition); db.SaveChanges(); return(StatusCode(HttpStatusCode.NoContent)); } else { return(Unauthorized()); } }
/// <summary> /// 获取数据列表(分页) /// </summary> public PageModel GetDataListForPage(DistributionDeclareRequest request) { #region 模糊搜索条件 var where = new Where <TbDistributionDeclare>(); if (!string.IsNullOrWhiteSpace(request.DistributionDeclareCode)) { where.And(d => d.DistributionDeclareCode == request.DistributionDeclareCode); } if (!string.IsNullOrWhiteSpace(request.ProcessFactoryCode)) { where.And(d => d.ProcessFactoryCode == request.ProcessFactoryCode); } #endregion #region 数据权限 //数据权限 var authorizaModel = new AuthorizeLogic().CheckAuthoriza(new AuthorizationParameterModel("DistributionDeclare")); if (authorizaModel.IsAuthorize) { if (authorizaModel.Ids.Count > 0 && authorizaModel.UserCodes.Count > 0) { where.And(d => d.InsertUserCode.In(authorizaModel.UserCodes) || d.ID.In(authorizaModel.Ids)); } else if (authorizaModel.Ids.Count > 0) { where.Or(d => d.ID.In(authorizaModel.Ids)); } else if (authorizaModel.UserCodes.Count > 0) { where.And(d => d.InsertUserCode.In(authorizaModel.UserCodes)); } } if (!string.IsNullOrEmpty(request.ProjectId)) { where.And(p => p.ProjectId == request.ProjectId); } #endregion try { var data = Db.Context.From <TbDistributionDeclare>() .Select( TbDistributionDeclare._.ID , TbDistributionDeclare._.Examinestatus , TbDistributionDeclare._.DistributionDeclareCode , TbDistributionDeclare._.DeclareTime , TbDistributionDeclare._.TotalAmount , TbDistributionDeclare._.InsertUserCode , TbDistributionDeclare._.InsertTime , TbDistributionDeclare._.ProjectId , TbUser._.UserName , TbCompany._.CompanyFullName.As("ProcessFactoryName")) .AddSelect(Db.Context.From <TbUser>() .Select(p => p.UserName) .Where(TbUser._.UserCode == TbDistributionDeclare._.DeclareUserCode), "DeclareUserName") .LeftJoin <TbUser>((a, c) => a.InsertUserCode == c.UserCode) .LeftJoin <TbCompany>((a, c) => a.ProcessFactoryCode == c.CompanyCode) .Where(where) .OrderByDescending(p => p.ID) .ToPageList(request.rows, request.page); return(data); } catch (Exception) { throw; } }