public ActionResult NewCatalogueValue(Guid? catalogueId)
 {
     CatalogueValue model = new CatalogueValue();
     model.CatalogueId = catalogueId.GetValueOrDefault();
     return View("CatalogueValue", model);
 }
 /// <summary>
 /// Create a new CatalogueValue object.
 /// </summary>
 /// <param name="catalogueValueId">Initial value of the CatalogueValueId property.</param>
 /// <param name="catalogueId">Initial value of the CatalogueId property.</param>
 /// <param name="catalogueValueData">Initial value of the CatalogueValueData property.</param>
 /// <param name="creationBy">Initial value of the CreationBy property.</param>
 /// <param name="creationDate">Initial value of the CreationDate property.</param>
 /// <param name="isDeleted">Initial value of the IsDeleted property.</param>
 public static CatalogueValue CreateCatalogueValue(global::System.Guid catalogueValueId, global::System.Guid catalogueId, global::System.String catalogueValueData, global::System.String creationBy, global::System.DateTime creationDate, global::System.Boolean isDeleted)
 {
     CatalogueValue catalogueValue = new CatalogueValue();
     catalogueValue.CatalogueValueId = catalogueValueId;
     catalogueValue.CatalogueId = catalogueId;
     catalogueValue.CatalogueValueData = catalogueValueData;
     catalogueValue.CreationBy = creationBy;
     catalogueValue.CreationDate = creationDate;
     catalogueValue.IsDeleted = isDeleted;
     return catalogueValue;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the CatalogueValues EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCatalogueValues(CatalogueValue catalogueValue)
 {
     base.AddObject("CatalogueValues", catalogueValue);
 }
        public static CatalogueValueModel SaveCatalogueValue(CatalogueValueModel model, string userName)
        {
            using (VestalisEntities context = new VestalisEntities())
            {

                bool existCatalogueValue = context.CatalogueValues.Any(data => data.IsDeleted == false
                        && data.CatalogueId == model.CatalogueId
                        && data.CatalogueValueData == model.CatalogValData);

                //if the CatalogueValueId is empty, the system will perform the insert operation
                //otherwise the system will perform the edit operation
                if (model.CatalogValId == null)
                {
                    //if the current catalogue is not exists, the system continues with the process
                    if (!existCatalogueValue)
                    {
                        CatalogueValue catalogueValue = new CatalogueValue();
                        catalogueValue.CatalogueValueData = model.CatalogValData;
                        catalogueValue.CatalogueValueDescription = model.CatalogDesc;
                        catalogueValue.CatalogueId = model.CatalogueId.GetValueOrDefault();
                        //set  auditory fields
                        catalogueValue.CreationBy = userName;
                        catalogueValue.CreationDate = DateTime.UtcNow;
                        //add the new object
                        context.CatalogueValues.AddObject(catalogueValue);
                        //save all changes
                        context.SaveChanges();
                    }
                    else
                    {
                        model.Errors.Add(LanguageResource.CatalogueValueExists);
                    }

                }
                else
                {
                    UpdateCatalogValue(model, userName, context, existCatalogueValue);
                }

                //Remove from the cache the catalogue
                Catalogue catalogue = GetCatalogueCategory(model.CatalogueId.GetValueOrDefault());
                CacheHandler.Remove(String.Format("{0}{1}", catalogue.CatalogueCategoryName, catalogue.BusinessApplicationId));

            }
            return model;
        }