public ActionResult Create(T_COM_Master_Entity model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             //  model.CreatedUser = CurrentUser.UserName;
             if (model.EntityId != 0)
             {
                 //get default value
                 //	T_COM_Master_Entity b = T_COM_Master_EntityManager.GetById(model.EntityId);
                 T_COM_Master_EntityManager.Update(model);
             }
             else
             {
                 // TODO: Add insert logic here
                 //	 model.CreatedDate = SystemConfig.CurrentDate;
                 T_COM_Master_EntityManager.Add(model);
             }
             return(View(ViewFolder + "list.cshtml", T_COM_Master_EntityManager.GetAll()));
         }
     }
     catch
     {
         return(View(model));
     }
     return(View(model));
 }
        public ContentResult Save(string objdata, string value)
        {
            JsonObject js = new JsonObject();

            js.StatusCode = 200;
            js.Message    = "Upload Success";
            try
            {
                T_COM_Master_Entity obj = JsonConvert.DeserializeObject <T_COM_Master_Entity>(objdata);
                obj = T_COM_Master_EntityManager.Update(obj);
                if (obj.EntityId == 0)
                {
                    js.StatusCode = 400;
                    js.Message    = "Has Errors. Please contact Admin for more information";
                }
                else
                {
                    js.Data = obj;
                }
            }
            catch (Exception objEx)
            {
                js.StatusCode = 400;
                js.Message    = objEx.Message;
            }

            return(Content(JsonConvert.SerializeObject(js), "application/json"));
        }
        /// <summary>
        /// use for setting up default value
        /// </summary>
        /// <returns></returns>
        public ActionResult Update(int EntityId, string TargetID = "T_COM_Master_Entitylist")
        {
            T_COM_Master_Entity objItem = T_COM_Master_EntityManager.GetById(EntityId);

            objItem.TargetDisplayID = TargetID;
            return(View(ViewFolder + "Create.cshtml", objItem));
        }
Ejemplo n.º 4
0
 public static void RemoveCache(T_COM_Master_Entity objItem)
 {
     //HttpCache.RemoveByPattern(SETTINGS_ALL_KEY);
     HttpCache.RemoveByPattern(string.Format(SETTINGS_ALL_KEY, CustomerAuthorize.CurrentUser.EmployeeCode));
     HttpCache.RemoveByPattern(string.Format(SETTINGS_ID_KEY, objItem.EntityId));
     //HttpCache.RemoveByPattern(string.Format(SETTINGS_User_KEY, objItem.CreatedUser));
     HttpCache.RemoveSearchCache(SystemConfig.AllowSearchCache, SETTINGS_Search_KEY);
 }
Ejemplo n.º 5
0
 public static void Delete(T_COM_Master_Entity objItem)
 {
     if (objItem != null)
     {
         using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
         {
             HttpResponseMessage response = client.DeleteAsync(string.Format(Resource + "/{0}", objItem.EntityId)).GetAwaiter().GetResult();
         }
         RemoveCache(objItem);
     }
 }
Ejemplo n.º 6
0
        public static T_COM_Master_Entity Update(T_COM_Master_Entity objItem)
        {
            T_COM_Master_Entity item = new T_COM_Master_Entity();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PutAsJsonAsync(string.Format(Resource + "/{0}", objItem.EntityId), objItem).GetAwaiter().GetResult();
                if (response.IsSuccessStatusCode)
                {
                    item = response.Content.ReadAsAsync <T_COM_Master_Entity>().GetAwaiter().GetResult();
                    RemoveCache(item);
                }
            }
            return(item);
        }
Ejemplo n.º 7
0
        public static T_COM_Master_Entity Add(T_COM_Master_Entity objItem)
        {
            T_COM_Master_Entity b = new T_COM_Master_Entity();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PostAsJsonAsync(Resource, objItem).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    b = response.Content.ReadAsAsync <T_COM_Master_Entity>().GetAwaiter().GetResult();
                }
            }
            RemoveCache(b);
            return(b);
        }
 public ActionResult Update(T_COM_Master_Entity model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             // TODO: Add insert logic here
             T_COM_Master_EntityManager.Update(model);
             //return RedirectToAction("Index");
         }
         return(View(model));
     }
     catch
     {
         return(View(model));
     }
 }
Ejemplo n.º 9
0
        public static T_COM_Master_Entity GetById(int id)
        {
            string key  = String.Format(SETTINGS_ID_KEY, id);
            object obj2 = HttpCache.Get(key);

            if (obj2 != null)
            {
                return((T_COM_Master_Entity)obj2);
            }

            T_COM_Master_Entity b = new T_COM_Master_Entity();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.GetAsync(string.Format(Resource + "?EntityId={0}", id)).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    b = response.Content.ReadAsAsync <T_COM_Master_Entity>().GetAwaiter().GetResult();
                }
            }
            HttpCache.Max(key, b);
            return(b);
        }
Ejemplo n.º 10
0
 // PUT api/<controller>/5
 /// <summary>
 /// Puts the specified identifier.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 /// <exception cref="HttpResponseException"></exception>
 public T_COM_Master_Entity Put(string id, [FromBody] T_COM_Master_Entity value)
 {
     return(T_COM_Master_EntityManager.UpdateItem(value));
 }
Ejemplo n.º 11
0
 // POST api/<controller>
 /// <summary>
 /// Posts the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns></returns>
 public T_COM_Master_Entity Post([FromBody] T_COM_Master_Entity value)
 {
     return(T_COM_Master_EntityManager.AddItem(value));
 }
        public ActionResult Get(int EntityId, string action)
        {
            T_COM_Master_Entity objItem = T_COM_Master_EntityManager.GetById(EntityId);

            return(Content(JsonConvert.SerializeObject(objItem), "application/json"));
        }
        public ActionResult Get(int EntityId)
        {
            T_COM_Master_Entity objItem = T_COM_Master_EntityManager.GetById(EntityId);

            return(View(objItem));
        }