public static async Task <String> UpdateEvent(EventInputData eventInput, EventCatalogContext catalogContext, IFormFile File, IWebHostEnvironment env)
        {
            EventItem eventItem = new EventItem();

            try
            {
                eventItem.Event_Name        = eventInput.Inp_Event_Name;
                eventItem.Event_Desc        = eventInput.Inp_Event_Desc;
                eventItem.Event_Capacity    = eventInput.Inp_Event_Capacity;
                eventItem.Event_Start_Time  = eventInput.Inp_Start_Time;
                eventItem.Event_End_Time    = eventInput.Inp_End_Time;
                eventItem.Event_Price       = eventInput.Inp_Price;
                eventItem.Event_Address     = eventInput.Inp_Address;
                eventItem.Event_Online_Link = eventInput.Inp_Online_Link;

                if (File != null)
                {
                    eventItem.Event_Pictureurl = File.FileName;
                    var result = await upload_file(File, env);

                    if (result != "Ok")
                    {
                        return(result);
                    }
                }
                else
                {
                    eventItem.Event_Pictureurl = "Picture Not Provided";
                }

                int key = 0;


                if (eventInput.Inp_Event_Category != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Category, catalogContext, "Category");

                    eventItem.Event_CategoryId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Category == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Category is null"));
                }


                if (eventInput.Inp_Event_Audience != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Audience, catalogContext, "Audiences");

                    eventItem.Event_AudienceId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Audience == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Audience is null"));
                }


                if (eventInput.Inp_Event_Format != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Format, catalogContext, "Format");

                    eventItem.Event_FormatId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Format == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Format is null"));
                }


                if (eventInput.Inp_Event_Kind != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Kind, catalogContext, "Kind");

                    eventItem.Event_KindId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Kind == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Kind is null"));
                }

                if (eventInput.Inp_Event_Location != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Location, catalogContext, "Location");

                    eventItem.Event_LocationId = key;
                }

                if (key == 0 || eventInput.Inp_Event_Location == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Location is null"));
                }


                if (eventInput.Inp_Event_Language != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Language, catalogContext, "Language");

                    eventItem.Event_LanguageId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Language == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Language is null"));
                }

                if (eventInput.Inp_Event_ZipCode != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_ZipCode, catalogContext, "ZipCode");

                    eventItem.Event_ZipCodeId = key;
                }

                if (key == 0 || eventInput.Inp_Event_ZipCode == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_ZipCode is null"));
                }

                if (eventInput.Inp_Event_User != null)
                {
                    var user = catalogContext.EventUserInfos
                               .Where(b => b.UserName == eventInput.Inp_Event_User)
                               .FirstOrDefault();
                    if (user == null)
                    {
                        throw new ArgumentNullException(String.Format("Inp_Event_user not found"));
                    }
                    eventItem.Event_UserId = user.UserName;
                }
                if (eventItem.Event_UserId == null || eventInput.Inp_Event_User == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_user is null"));
                }



                await catalogContext.EventItems.AddAsync(eventItem);

                catalogContext.SaveChanges();

                return("Event Addition Succesful");
            }

            catch (ArgumentNullException ex)
            {
                return(ex.GetType().Name + ex.Message);
            }
        }
        private static async Task <int> FindForeignKey(String search_str, EventCatalogContext catalogContext, string table_type)
        {
            try
            {
                if (table_type == "Category")
                {
                    var category = await catalogContext.EventCategories
                                   .Where(b => b.Event_Category == search_str)
                                   .FirstOrDefaultAsync();

                    if (category != null)
                    {
                        return(category.Id);
                    }
                }

                if (table_type == "Location")
                {
                    var location = await catalogContext.EventLocations
                                   .Where(b => b.Event_Location == search_str)
                                   .FirstOrDefaultAsync();

                    if (location != null)
                    {
                        return(location.Id);
                    }
                }
                if (table_type == "Format")
                {
                    var format = await catalogContext.EventFormats
                                 .Where(b => b.Event_Format == search_str)
                                 .FirstOrDefaultAsync();

                    if (format != null)
                    {
                        return(format.Id);
                    }
                }
                if (table_type == "Kind")
                {
                    var kind = await catalogContext.EventKinds
                               .Where(b => b.Event_Kind == search_str)
                               .FirstOrDefaultAsync();

                    if (kind != null)
                    {
                        return(kind.Id);
                    }
                }



                if (table_type == "Audiences")
                {
                    var Audience = await catalogContext.EventAudiences
                                   .Where(b => b.Event_AgeGroup == search_str)
                                   .FirstOrDefaultAsync();

                    if (Audience != null)
                    {
                        return(Audience.Id);
                    }
                }
                if (table_type == "Language")
                {
                    var Language = await catalogContext.EventLanguages
                                   .Where(b => b.Event_Language == search_str)
                                   .FirstOrDefaultAsync();

                    if (Language != null)
                    {
                        return(Language.Id);
                    }
                }



                if (table_type == "ZipCode")
                {
                    var Zipcode = await catalogContext.EventZipCodes
                                  .Where(b => b.Event_Zipcode == search_str)
                                  .FirstOrDefaultAsync();

                    if (Zipcode != null)
                    {
                        return(Zipcode.Id);
                    }
                }
                return(0);
            }
            catch (Exception)
            {
                return(0);
            }
        }
        public static async Task <String> UpdateEvent(EventInputData eventInput, EventCatalogContext catalogContext, IFormFile File, IWebHostEnvironment env)
        {
            EventItem eventItem = new EventItem();

            try
            {
                eventItem.Event_Name       = eventInput.Inp_Event_Name;
                eventItem.Event_Desc       = eventInput.Inp_Event_Desc;
                eventItem.Event_Organiser  = eventInput.Inp_Event_Organiser;
                eventItem.Event_Start_Time = eventInput.Inp_Start_Time;
                eventItem.Event_End_Time   = eventInput.Inp_End_Time;
                eventItem.Event_Price      = eventInput.Inp_Price;

                if (File != null)
                {
                    eventItem.Event_Pictureurl = File.FileName;
                    var result = await upload_file(File, env);

                    if (result != "Ok")
                    {
                        return(result);
                    }
                }
                else
                {
                    eventItem.Event_Pictureurl = "Picture Not Provided";
                }

                int key = 0;


                if (eventInput.Inp_Event_Category != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Category, catalogContext, "Category");

                    eventItem.Event_CategoryId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Category == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Category is null"));
                }


                if (eventInput.Inp_Event_Audience != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Audience, catalogContext, "Audiences");

                    eventItem.Event_AudienceId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Audience == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Audience is null"));
                }


                if (eventInput.Inp_Event_Format != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Format, catalogContext, "Format");

                    eventItem.Event_FormatId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Format == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Format is null"));
                }


                if (eventInput.Inp_Event_Kind != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Kind, catalogContext, "Kind");

                    eventItem.Event_KindId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Kind == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Kind is null"));
                }

                if (eventInput.Inp_Event_Location != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Location, catalogContext, "Location");

                    eventItem.Event_LocationId = key;
                }

                if (key == 0 || eventInput.Inp_Event_Location == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Location is null"));
                }


                if (eventInput.Inp_Event_Language != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_Language, catalogContext, "Language");

                    eventItem.Event_LanguageId = key;
                }
                if (key == 0 || eventInput.Inp_Event_Language == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_Language is null"));
                }

                if (eventInput.Inp_Event_ZipCode != null)
                {
                    key = await FindForeignKey(eventInput.Inp_Event_ZipCode, catalogContext, "ZipCode");

                    eventItem.Event_ZipCodeId = key;
                }

                if (key == 0 || eventInput.Inp_Event_ZipCode == null)
                {
                    throw new ArgumentNullException(String.Format("Inp_Event_ZipCode is null"));
                }



                try
                {
                    await catalogContext.EventItems.AddAsync(eventItem);

                    catalogContext.SaveChanges();
                }
                catch (DbUpdateException ex)
                {
                    return("DB UPDATE FAILED");
                }

                return("Event Addition Succesful");
            }

            catch (ArgumentNullException ex)
            {
                return(ex.GetType().Name + ex.Message);
            }
        }