public Int32 insertArticleComponent(Models.MstArticleComponent component) { try { Data.MstArticleComponent newComponent = new Data.MstArticleComponent(); newComponent.ArticleId = component.ArticleId; newComponent.ComponentArticleId = component.ComponentArticleId; newComponent.Quantity = component.Quantity; newComponent.Particulars = component.Particulars; db.MstArticleComponents.InsertOnSubmit(newComponent); db.SubmitChanges(); return(newComponent.Id); } catch { return(0); } }
public Int32 insertArticleComponent(Models.MstArticleComponent component) { try { Data.MstArticleComponent newComponent = new Data.MstArticleComponent(); newComponent.ArticleId = component.ArticleId; newComponent.ComponentArticleId = component.ComponentArticleId; newComponent.Quantity = component.Quantity; newComponent.Particulars = component.Particulars; db.MstArticleComponents.InsertOnSubmit(newComponent); db.SubmitChanges(); return newComponent.Id; } catch { return 0; } }
public HttpResponseMessage AddItemComponent(Entities.MstArticleComponent objItemComponent, String itemId) { try { var currentUser = from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d; if (currentUser.Any()) { var currentUserId = currentUser.FirstOrDefault().Id; var userForms = from d in db.MstUserForms where d.UserId == currentUserId && d.SysForm.FormName.Equals("ItemDetail") select d; if (userForms.Any()) { if (userForms.FirstOrDefault().CanAdd) { var item = from d in db.MstArticles where d.Id == Convert.ToInt32(itemId) && d.ArticleTypeId == 1 select d; if (item.Any()) { if (!item.FirstOrDefault().IsLocked) { Data.MstArticleComponent newItemComponent = new Data.MstArticleComponent { ArticleId = Convert.ToInt32(itemId), ComponentArticleId = objItemComponent.ComponentArticleId, Quantity = objItemComponent.Quantity, Particulars = objItemComponent.Particulars }; db.MstArticleComponents.InsertOnSubmit(newItemComponent); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "You cannot add new component if the current item detail is locked.")); } } else { return(Request.CreateResponse(HttpStatusCode.NotFound, "These current item details are not found in the server. Please add new item first before proceeding.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no rights to add new component in this item detail page.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Sorry. You have no access in this item detail page.")); } } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Theres no current user logged in.")); } } catch (Exception e) { Debug.WriteLine(e); return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Something's went wrong from the server.")); } }