public ActionResult DeleteAttribute(string PointId, string AttributeID) { if (PointId == null || PointId.Equals(string.Empty) || AttributeID == null || AttributeID.Equals(string.Empty)) { return(Content(ViewRes.Attribute.MissingParams)); } try { PointAttributeModel point = service.GetAttribute(new Guid(AttributeID)); if (point != null) { service.DeleteAttribute(point); return(Content("Sucesso")); } else { return(Content(ViewRes.SharedStrings.NotExists)); } } catch (UpdateException) { return(Content(ViewRes.Attribute.UpdateException)); } catch (Exception e) { if (e.InnerException != null) { return(Content(e.InnerException.Message)); } return(Content(e.Message)); } }
public Guid InsertPointAttribute(PointAttributeModel pointAttribute) { if (pointAttribute == null) { throw new NullReferenceException("pointAttribute"); } using (AppTourEntities data = new AppTourEntities()) { POINTS_ATTRIBUTES novo = new POINTS_ATTRIBUTES { ID = (pointAttribute.Id == null || pointAttribute.Id == Guid.Empty ? Guid.NewGuid() : pointAttribute.Id), POINT = data.POINT.Single(x => x.ID.Equals(pointAttribute.Point.Id)), KEYPAIR = pointAttribute.KeyPair, VALUE_BOOL = pointAttribute.Value_bool, VALUE_STRING = pointAttribute.Value_string, VALUE_DATE = pointAttribute.Value_Date, VALUE_NUMBER = pointAttribute.Value_number, VALUE_TYPE = pointAttribute.Value_Type, IS_ACTIVE = pointAttribute.IsActive }; data.POINTS_ATTRIBUTES.AddObject(novo); data.SaveChanges(); return(novo.ID); } }
public void DeletePointAttribute(PointAttributeModel pointAttributeModel) { if (pointAttributeModel == null) { throw new ArgumentNullException("pointAttributeModel"); } using (AppTourEntities data = new AppTourEntities()) { try { POINTS_ATTRIBUTES current = data.POINTS_ATTRIBUTES.Single(p => p.ID == pointAttributeModel.Id); if (current != null) { data.POINTS_ATTRIBUTES.DeleteObject(current); data.SaveChanges(); } } catch (Exception e) { if (e.InnerException != null) { throw new Exception(e.InnerException.Message); } throw; } } }
public ActionResult InsertAttribute(string PointId, string attrkey, string attrvalue, string attrtype, string active) { if (PointId == null || PointId.Equals(string.Empty) || attrkey == null || attrkey.Equals(string.Empty) || attrvalue == null || attrvalue.Equals(string.Empty) || attrtype == null || attrtype.Equals(string.Empty)) { return(Content(ViewRes.Attribute.MissingParams)); } try { bool isActive = (active != null ? true : false); PointAttributeModel model = new PointAttributeModel { Id = Guid.NewGuid(), Point = new PointService().GetPoint(new Guid(PointId)), KeyPair = attrkey, Value_bool = (attrtype.Equals("System.Boolean") ? (attrvalue.ToLower().Equals("true") || attrvalue.ToLower().Equals("1") ? true : false) : (bool?)null), Value_number = (attrtype.Equals("System.Decimal") ? Convert.ToDecimal(attrvalue, CultureInfo.GetCultureInfo("en-US")) : (Decimal?)null), Value_Date = (attrtype.Equals("System.DateTime") ? DateTime.Parse(attrvalue) : (DateTime?)null), Value_string = (attrtype.Equals("System.String") ? attrvalue : null), Value_Type = attrtype, IsActive = isActive }; Guid id = service.InsertAttribute(model); return(Content("Sucesso")); } catch (Exception e) { if (e.InnerException != null) { return(Content(e.InnerException.Message)); } return(Content(e.Message)); } }
public void UpdateAttribute(PointAttributeModel pointAttributeModel) { if (pointAttributeModel == null) { throw new ArgumentNullException("pointAttributeModel"); } using (AppTourEntities data = new AppTourEntities()) { try { POINTS_ATTRIBUTES current = data.POINTS_ATTRIBUTES.Single(p => p.ID == pointAttributeModel.Id); if (current != null) { current.KEYPAIR = pointAttributeModel.KeyPair; current.VALUE_BOOL = pointAttributeModel.Value_bool; current.VALUE_DATE = pointAttributeModel.Value_Date; current.VALUE_NUMBER = pointAttributeModel.Value_number; current.VALUE_STRING = pointAttributeModel.Value_string; current.VALUE_TYPE = pointAttributeModel.Value_Type; current.IS_ACTIVE = pointAttributeModel.IsActive; data.SaveChanges(); } } catch (Exception e) { if (e.InnerException != null) { throw new Exception(e.InnerException.Message); } throw; } } }
public void DeleteAttribute(PointAttributeModel pointAttributeModel) { new PointAttributeRepository().DeletePointAttribute(pointAttributeModel); }
public Guid InsertAttribute(PointAttributeModel pointAttributeModel) { return(new PointAttributeRepository().InsertPointAttribute(pointAttributeModel)); }
public void UpdateAttribute(PointAttributeModel pointAttributeModel) { new PointAttributeRepository().UpdateAttribute(pointAttributeModel); }