/*revisar!!*/ public JsonResult PostMessage(Comment comment, string url, string id) { var userId = User.Identity.GetUserId(); var userName = us.Users.Where(x => x.Id == userId).Select(x => x.Nombre).SingleOrDefault(); GenerateId generator = new GenerateId(); comment.CommentId = generator.generateID(); comment.Fk_Post = id; comment.Fk_User = userId; comment.Date = DateTime.Now; if (comment.CommentMessage != null) { db.Comments.Add(comment); db.SaveChanges(); } var mail = us.Users.Where(x => x.Id == userId).Select(x => x.Email).SingleOrDefault(); var foto = us.Users.Where(x => x.Id == userId).Select(x => x.Foto).SingleOrDefault(); var obj = new { date = comment.Date, message = comment.CommentMessage, user = userName, mail = mail, foto = foto, url = url }; return(Json(new { data = obj, postId = comment.CommentId }, JsonRequestBehavior.AllowGet)); }
public JsonResult Create([Bind(Include = "WarehouseID,NumberCode,Fk_BranchID,CreationDate,Fk_ShipperID,Fk_Consignee,Fk_Agent,Fk_DeliveryCompany,Fk_Condition,Description,Fk_Origin,Fk_Destination")] Warehouse wareHouse, List <Courier> courier, string[] types) { GenerateId generator = new GenerateId(); wareHouse.WarehouseID = generator.generateID(); db.Warehouses.Add(wareHouse); db.SaveChanges(); ////Add Types List <WarehouseTypeRelation> typeList = new List <WarehouseTypeRelation>(); foreach (var item in types) { var idType = db.WarehouseTypes.Where(x => x.TypeName == item).Select(x => x.TypeId).SingleOrDefault(); WarehouseTypeRelation typeItem = new WarehouseTypeRelation(); typeItem.WarehouseTypeRelationId = generator.generateID(); typeItem.WarehouseId = wareHouse.WarehouseID; typeItem.TypeId = idType; typeList.Add(typeItem); } foreach (var item in courier) { Courier courierItem = new Courier(); item.CourierID = generator.generateID(); item.CreationDate = DateTime.Now; item.Deleted = false; item.Fk_WarehouseID = wareHouse.WarehouseID; db.Couriers.Add(item); } foreach (var item in typeList) { db.WarehouseTypeRelations.Add(item); } db.SaveChanges(); return(Json(new { }, JsonRequestBehavior.AllowGet)); }
public JsonResult Create([Bind(Include = "TypeId,TypeName")] WarehouseType warehouseClassification) { GenerateId generator = new GenerateId(); warehouseClassification.TypeId = generator.generateID(); db.WarehouseTypes.Add(warehouseClassification); db.SaveChanges(); var tipo = new { TypeId = warehouseClassification.TypeId, TypeName = warehouseClassification.TypeName }; return(Json(new { data = tipo }, JsonRequestBehavior.AllowGet)); }
public JsonResult Create([Bind(Include = "ConditionID,ConditionName")] Condition condition) { GenerateId generator = new GenerateId(); condition.ConditionID = generator.generateID(); db.Conditions.Add(condition); db.SaveChanges(); var condicion = new { ConditionID = condition.ConditionID, ConditionName = condition.ConditionName }; return(Json(new { data = condicion }, JsonRequestBehavior.AllowGet)); }
public JsonResult Create([Bind(Include = "AccountClasificationID,ClasificationName")] AccountClasification classification) { GenerateId generator = new GenerateId(); classification.AccountClasificationID = generator.generateID(); db.AccountClasifications.Add(classification); db.SaveChanges(); var clasificacion = new { Id = classification.AccountClasificationID, Classification = classification.ClasificationName }; return(Json(new { data = clasificacion }, JsonRequestBehavior.AllowGet)); }
public JsonResult Create([Bind(Include = "CompanyID,CompanyName")] DeliveryCompany deliveryCompany) { GenerateId generator = new GenerateId(); deliveryCompany.CompanyID = generator.generateID(); db.DeliveryCompanies.Add(deliveryCompany); db.SaveChanges(); var delivery = new { Id = deliveryCompany.CompanyID, CompanyName = deliveryCompany.CompanyName }; return(Json(new { data = delivery }, JsonRequestBehavior.AllowGet)); }
public JsonResult Create([Bind(Include = "DestinationId,DestinationName")] Destination destination) { GenerateId generator = new GenerateId(); destination.DestinationId = generator.generateID(); db.Destinations.Add(destination); db.SaveChanges(); var destino = new { DestinationId = destination.DestinationId, DestinationName = destination.DestinationName }; return(Json(new { data = destino }, JsonRequestBehavior.AllowGet)); }
public void CreateUserPost(String PostId, String UserId) { // First is needed to check if the relation alredy exist var Relation = db.PostUsers.Where(x => x.Fk_Post == PostId && x.Fk_User == UserId).Select(x => x.PostUserID); if (Relation.Count() == 0 && PostId != null && UserId != null) { GenerateId generator = new GenerateId(); PostUser postRelation = new PostUser(); postRelation.PostUserID = generator.generateID(); postRelation.Fk_Post = PostId; postRelation.Fk_User = UserId; db.PostUsers.Add(postRelation); db.SaveChanges(); } }
public JsonResult CreatePost(Post postEntry) { GenerateId generator = new GenerateId(); var userId = User.Identity.GetUserId(); postEntry.PostID = generator.generateID(); postEntry.PubDate = DateTime.Now; db.Posts.Add(postEntry); db.SaveChanges(); CreateUserPost(postEntry.PostID, userId); var post = new { id = postEntry.PostID, title = postEntry.Title, description = postEntry.Description, date = postEntry.PubDate, }; return(Json(new { data = post }, JsonRequestBehavior.AllowGet)); }
public JsonResult Create([Bind(Include = "CompanyAccountID,CompanyName,Adress,City,State,ZipCode,Fk_CountryID,Email,Phone,Fax,Mobile,ContactName,Fk_Agent")] CompanyAccount CompanyAccount, String[] Classification, String[] Notification) { GenerateId generator = new GenerateId(); CompanyAccount.CompanyAccountID = generator.generateID(); db.CompanyAccounts.Add(CompanyAccount); db.SaveChanges(); if (Classification != null) { ////Add classifications List <AccountClasificationRelation> classificationAccountList = new List <AccountClasificationRelation>(); foreach (var item in Classification) { var idClassification = db.AccountClasifications.Where(x => x.ClasificationName == item).Select(x => x.AccountClasificationID).SingleOrDefault(); AccountClasificationRelation classificacationItem = new AccountClasificationRelation(); classificacationItem.AccountClasificationID = generator.generateID(); classificacationItem.Fk_AccountID = CompanyAccount.CompanyAccountID; classificacationItem.Fk_ClasificationID = idClassification; classificationAccountList.Add(classificacationItem); } foreach (var item in classificationAccountList) { db.AccountClasificationRelations.Add(item); } } if (Notification != null) { ////Add notifications List <NotificationAccountRelation> notificationAccountList = new List <NotificationAccountRelation>(); foreach (var item in Notification) { var idNotification = db.Notifications.Where(x => x.NotificationName == item).Select(x => x.NotificationID).SingleOrDefault(); NotificationAccountRelation notificationItem = new NotificationAccountRelation(); notificationItem.NotificationAccountRelation1 = generator.generateID(); notificationItem.Fk_Account = CompanyAccount.CompanyAccountID; notificationItem.Fk_Notification = idNotification; notificationAccountList.Add(notificationItem); } foreach (var item in notificationAccountList) { db.NotificationAccountRelations.Add(item); } } var account = new { CompanyAccountID = CompanyAccount.CompanyAccountID, CompanyName = CompanyAccount.ContactName, Adress = CompanyAccount.Adress, City = CompanyAccount.City, State = CompanyAccount.State, }; db.SaveChanges(); return(Json(new { data = account }, JsonRequestBehavior.AllowGet)); }